Data Type: Numeric
Any valid numeric expression.
Initializes the random number generator.
number as a new seed value to
initialize the random number generator used by the
Rnd function. The seed value is an
initial value that generates a sequence of pseudorandom
If you don’t pass
number to the
Randomize statement, the
value of the system timer is used as the new seed value.
Repeatedly passing the same number to
Randomize doesn’t cause
Rnd to repeat the same sequence of
Randomize is not
used and the
is called either with no argument or with 1 as an argument, the
Rnd function always uses the same number as
the seed value the first time it is called, and subsequently
uses the last generated number as a seed value.
If you need to repeat a sequence of random numbers, you should
Rnd function with a
negative number as an argument immediately prior to using
Randomize with any numeric argument. This
is illustrated in the example program.
RepeatNumbers() Sub RepeatNumbers() Dim arr(9, 3) Dim loopCtr, intCtr Dim strMsg For loopCtr = 0 To 3 Rnd -1 Randomize(100) For intCtr = 0 To 9 strMsg = strMsg & Rnd() & " " Next strMsg = strMsg & vbCrLf Next MsgBox strMsg End Sub