Answer for:

How to generate random numbers in a text box.

Message 7 of 10

View entire thread
0 Votes

The Randomize function seeds the rnd() function with the timer (if no other parameter is specified). You need to "re-seed" each time or you'll get the same sequence of numbers. Then you use the next statement to generate the random number - setting the upper and lower limits.

Dim iRand As Integer

nRand = Int((MaxNum - MinNum + 1) * Rnd + MinNum)