Rnd()

Syntax

Rnd()

Remarks

Returns a random real number greater than or equal to 0 (zero) and less than 1.
To generate a random integer between a and b, use the following syntax:

Int(Rnd() * ((b + 1)a) + a)

Example

This example defines the variable num as a random integer between 50 and 100 and then displays the number in a message box:


a = 50
b = 100
num = Int(Rnd() * (b - a) + a)
MsgBox "The random number is" + Str$(num)

See Also

Abs(), Int(), Sgn()