Method: Randomize for VBS
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: Randomize for VBS
Method: Randomize for VBS
Restarts the random number generator.
Object.Randomize(number)
| Object | VBS Object with this method. You do not need to specify this object. |
| number | Variant Specifies any numeric expression. If you do not enter a value, the Randomize method uses the current time value. If you do not call Randomize, the Rnd method always generates the same random number sequence when called. |
The following example generates random numbers between 0 and 10:
Dim MyValue, MyResponse Call Randomize ' Initialize random-number generator. Do Until MyResponse = vbNo MyValue = Int(11 * Rnd) ' Generate random value between 0 and 10. Call MsgBox (MyValue) MyResponse = MsgBox ("Again? ", vbYesNo) Loop