Randomize statement
Initialize the random number generator.
Randomize[Number]
NumberA parameter can be any valid numeric expression.
Description
RandomizeUseNumberParameter initializationRndThe random number generator of the function, which is assigned a new seed value. If omittedNumber, Use the value returned by the system timer as the new seed value.
If you do not useRandomize, The first callRndWhen a function (without parameters) is used, it uses the same number as the seed value, and then uses the final generated value as the seed value.
Note:To repeat the sequence of random numbers, call it using numerical parameters.RandomizePreviously, it was called immediately with a negative value ParameterRnd. Use the sameNumberValueRandomizeThe previous random number sequence cannot be repeated.
The following example illustrates how to useRandomizeStatement:
Dim MyValue, ResponseRandomize'
Initialize the random number generator.Do Until Response = vbNo
MyValue = Int (6 * Rnd) + 1 )'
Generate1
To6
Between.MsgBox MyValue
Response = MsgBox ("Roll again? ", VbYesNo)
Loop