I would like to know if there is a way to get a random letter (from A-Z)
Thanks for any help.
I think this is what you're looking for. Generate a Random Letter in ASP:
Function RandomNumber(LowNumber, HighNumber)
RANDOMIZE
RandomNumber = Round((HighNumber - LowNumber + 1) * Rnd + LowNumber)
End Function
Assign the function to a variable and pass in the LowNumber (26) and the HighNumber (97) and convert the value returned to the character it represents:
RandomLetter = CHR(RandomNumber(97,122))
You'll want your range to be between 65 and 90 (A and Z) for capital letters.
Roger Baretto's answer fixed with Cem's hint ))
Function RandomString(iSize)
Const VALID_TEXT = "abcdefghijklmnopqrstuvwxyz1234567890"
Dim Length, sNewSearchTag, I
Length = Len(VALID_TEXT)
Randomize()
For I = 1 To iSize
sNewSearchTag = sNewSearchTag & Mid(VALID_TEXT, Int(Rnd()*Length + 1), 1)
Next
RandomString = sNewSearchTag
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With