Purpose
Initializes the random number generator to seed new random numbers (Rnd calls).
Note
If Randomize isn't used, the Rnd function will return the same list of random numbers every time it is run.
Syntax
Randomize [Seed]
Seed |
The numeric key from which to generate the random number list. Using the same seed value each time a program is run will generate the same list of random numbers. If this argument is omitted, Randomize generates a number list using the Timer function. This provides a different seed value than the value used in any previous calls. |
Example
The following example demonstrates how Randomize can be used to create a new list of random numbers each time the program is run.
Sub Main ()
Dim i As Integer
Randomize
Print "Generating 25 random numbers from 1 to 100*
For i = 1 to 25
Print (100 * Rnd) + 1
Next i
End Sub
|