I want to make a random character generator with numbers in vb.net, I know how to make a random number generator but not numbers mixed with letters. I want it to be around 15-20 characters. Something like this: F53Gsfdsj637jfsj5kd8
Thanks ahead!
I want to make a random character generator with numbers in vb.net, I know how to make a random number generator but not numbers mixed with letters. I want it to be around 15-20 characters. Something like this: F53Gsfdsj637jfsj5kd8
Thanks ahead!
You're mostly there once you have a random number generator. From there, just pick a random character within a collection of valid characters. The simplest way would be something like:
dim validchars as string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
dim sb as new StringBuilder()
dim rand as new Random()
for i as Integer = 1 to 10
dim idx as Integer = rand.Next(0, validchars.Length)
dim randomChar as char = validchars(idx)
sb.Append(randomChar)
next i
dim randomString = sb.ToString()
Of course, clean up the syntax a bit, and maybe use a constant value for the chars and length, a variable value for the number of digits, etc.