Click to See Complete Forum and Search --> : Random number generator
How would create a random number generator between the limits of 1 and 20 for a multiple choice test??
hayessj
Dec 12th, 1999, 04:41 PM
See the VB help on the Rnd function
Private Function RandomNum() As Integer
RandomNum = Int((20 - 1 + 1) * Rnd + 1)
End Function
MartinLiss
Dec 12th, 1999, 08:27 PM
Add Randomize to hayessj's soultion or your set of random numbers will repeat each time you run the program.
Private Function RandomNum() As Integer
Randomize
RandomNum = Int((20 - 1 + 1) * Rnd + 1)
End Function
------------------
Marty
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.