RandomNumber(10)
Function RandomNumber(intHighestNumber)
Randomize
RandomNumber = Round(Rnd * intHighestNumber) + 1
End Function
What is you want to generate a random number between two other numbers, like between 20 and 40?
RandomNumber(20,40)
Function RandomNumber(LowNumber, HighNumber)
RANDOMIZE
RandomNumber = Round((HighNumber - LowNumber + 1) * Rnd + LowNumber)
End Function
2 comments:
The second function does not need the "+1" in it. if you use the example you will get numbers from 20-41 inclusive.
This is a great ASP snippet. I was forced to do some coding in classic ASP, thank you so much for your code, you saved my day! I need to simply generate a random number. :)
Thanks yo!
Post a Comment