Obtains a random whole number between 1 and a specified upper limit.
Rand ( n )
Argument |
Description |
---|---|
n |
The upper limit of the range of random numbers you want returned. The lower limit is always 1. The upper limit is 32,767. |
A numeric datatype, the datatype of n. Returns a random whole number between 1 and n inclusive. If n is null, Rand returns null.
The sequence of numbers generated by repeated calls to the Rand function is a pseudorandom sequence. You can control whether the sequence is different each time your application runs by calling the Randomize function to initialize the random number generator.
This statement returns a random whole number between 1 and 10:
Rand(10)