does anyone know how to make a textbox generate random letters as its text? code, please, and yes, its VB if u didnt read the subject :p
randomize timer
for iIndex = 0 to iAmount
txtBlah = txtBlah + chr(int(rnd * 26) + asc("A"))
next
This is totally untested, but should fill txtBlah with iAmount random capital characters
i use this for random hex char's, it might be able to get you at least started:
Public Function RandomLetter(finished As Long) As String
Randomize
Dim anus As Long
anus = Int((Val(finished) * Rnd) + 1)
RandomLetter = Hex(anus)
End Function
just replace hex(anus) with chr(anus) and it should be fine.
Public Function RandomString(Length As Long) As String
Dim lLetters As String, uLetters As String
lLetters = "1a2b3c4d5e6f7g8h9i0jklmnopqrstuv"
uLetters = "ABCDEFGHIJKLM1N2O3P4Q5R6S7T8U9V0"
For I = 1 To Length
If Int(Rnd * 2) = 1 Then
Randomize
RandomString = RandomString & Mid$(lLetters, Int(Rnd * 32), 1)
Else
Randomize
RandomString = RandomString & Mid$(uLetters, Int(Rnd * 22), 1)
End If
Next I
End Functionthis'll generate a random string containing lowercase/uppercase and the numbers 1-9
usage:
Text1 = RandomString(10)
thx that helped a lot