So I have this function which generates a random string of digits 8 characters long. It works if its called once per page, ie if I refresh it will show a new number.
But I want to generate many of these inside a loop and its returning the same number. How can I solve this?
Function generateCode()
pChar = "0123456789"
pCount = Len(pChar)
Dim psw
psw = ""
Randomize
For i = 1 To 8 ' password length
psw = psw & Mid( pChar, 1 + Int(Rnd * pCount), 1 )
Next
generateCode= psw
End Function
Now I thought Randomize may be based off the current time, so I took the Randomize line out and called Randomize before the loop that calls generateCode() i- still didn't work!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…