Rnd Function
Language Items List
Definition:
Returns a random number of data type Single.
Syntax:
Rnd[(number)]
Syntax Description
number Any valid numeric expression
Details:
Rnd returns a single-precision value that is between 0 and 1.
This function returns the next random number in the sequence started from the
initial seed value.. Each successive call to Rnd uses the previous random
number as a seed for the next number in the random-number sequence. The value of number determines how Rnd returns a random number as shown in the following table:
To return... Enter a number...
The same number every time, as determined by number. < 0
The next random number in the sequence. > 0
The random number that was generated most recently. = 0
The next random number in the sequence. number omitted
Use the Randomize statement without an argument before calling Rnd to generate
a different random-number sequence each time the program is run.
To generate a specific range of random integers, use the following equation
where upperbound is the maximum of the range, and lowerbound is the minimum:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
See Also:
Randomize Statement