Description
Returns a random numeric integer. You can use the InitRnd statement to initialize the Rnd function.
Syntax
random = Rnd (expression)
Parameters
The Rnd function has the following parameters.
Parameter | Description |
---|---|
Expression | Any legal BASIC+ expression. |
The Rnd function returns a random number that is from 0 (zero) to 1 (one) less than the designated number. For example, in
N = Rnd(501)
the variable identifier N will be assigned a random number from 0 to 500. Note that 0 (zero) is a possible number in the random selection.
An expression designating null or (0) returns a (0). A negative expression returns a negative random number.
See also
Example
/* Assigns a number between 0 and 99. */ random_num = Rnd(100) + 1