I believe many people have heard of Rnd function, so do you know about Rnd function? What is the usage of Rnd function? The following is a brief introduction to the Rnd function in Asp. Interested friends will take a look.
Rnd function
describe
Returns a random number.
grammar
Rnd[(number)]
The number parameter can be any valid numeric expression.
illustrate
The Rnd function returns a value less than 1 but greater than or equal to 0. The value of number determines how Rnd generates random numbers:
If number is generated for Rnd
A value less than zero is the same every time, using number as seed.
Greater than the next random number in the zero sequence.
The most recent number generated equals zero.
The next random number in the sequence is omitted.
Because the previous number in the sequence is used as the seed of the next number every time the Rnd function is called continuously, the same sequence is generated for any initially given seed.
Before calling Rnd, the random number generator is initialized with a parameterless Randomize statement, which has a seed based on the system timer.
To produce a random integer of the specified range, use the following formula:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the upper bound of this range, and lowerbound is the lower bound within this range.
--------------------------------------------------------------------------------------------------------------------------------
Note that to repeat the sequence of random numbers, call Rnd with the negative value parameter immediately before calling Randomize with the numerical parameters. Randomize with the same number value cannot repeat the previous sequence of random numbers.
--------------------------------------------------------------------------------------------------------------------------------
Example:
We usually use now() to make seeds, so that we can get a relatively perfect random sequence. If we need a random number within 1-100
Randomize()
n=Int((100-1+1)*Rnd(now())+1)
The above is an introduction to the Rnd function in asp. I believe everyone has a certain understanding. If you want to know more technical information, please continue to pay attention to the wrong new technology channel!