Description
Initializes the random-number generator.
Syntax
Randomize [number]
The number named argument can be any valid numeric expression.
Remarks
Randomize uses number to initialize a random-number generator, giving it a new seed value. If you omit number, the value returned by the Timer function is used as the new seed value.
If Randomize is not used, the same initial seed is always used to start the sequence.
Use the Randomize statement without an argument to provide a random seed based on the system timer to initialize the random-number generator before Rnd is called.
See Also
Rnd Function, Timer Function.
Example
This example uses the Randomize statement to initialize the random-number generator. Because the number argument has been omitted, Randomize uses the return value from the Timer function as the new seed value.
' Initialize random-number generator. Randomize ' Generate random value between 1 and 6. MyAngle = Int((6 * Rnd) + 1)