VBScript Rnd Function
Complete VBScript Reference Manual
The Rnd function returns a random number. The number is always less than 1 but greater than or equal to 0.
Syntax
Rnd[(number)]
| Parameters | Description |
|---|---|
| number | Optional. A valid numeric expression.
If the number is: |
Example
Example 1
Random numbers:
Note that you get the same number every time. To avoid this, use the Randomize statement as in Example 2.
The example above produces the following output:
0.7055475
Try it »
Example 2
To avoid getting the same number every time as in Example 1, use the Randomize statement:
The example above produces the following output:
0.4758112
Try it »
Example 3
Here is how to generate a random integer within a given range:
The example above produces the following output:
71
Try it »
Complete VBScript Reference Manual