There are times when we would need to generate random number, numbers that are in no particular order. We can use the Rnd( ) function.
Rnd( ) will return a value less than 1 and >= to zero.
To generate an integer value we can multiply the value returned by an appropriate number. To generate a random integer less than 100
Dim intRandomNumber
As Integer
intRandomNumber = Rnd( ) * 100
The Rnd() function uses a seed, or an initial value, to generate the random numbers. For any given initial seed, Rnd() will generate the same number sequence because each successive call to the Rnd() function uses the previous number as a seed for the next number in the sequence.
Before calling Rnd( ), use the Randomize statement to initialize the random-number generator with a seed based on the system timer
Dim intRandomNumber
As Integer
Randomize( )
intRandomNumber = Rnd() * 100