Rnd
The Rnd function generates a random number between 0 and 1.
Actually, it will generate a number that is greater than or equal
to zero and less than 1. It is important to note that the random
function will never return the value 1.
As you may notice, the random function returns a floating point
value. You can use the Int function along with some simple
math to convert this floating value into a random integer.
Before you call this function, you should always seed the random number generator with a call to Randomize first. This will ensure that the numbers generated by Rnd are truly random. Or at least, as random as a random number generator can create.
' always call the following function before using Rnd
Randomize Dim I ' first display 100 randoms
Response.Write "100 Randoms<BR>" For I = 1 To 100 Response.Write "Random(" & I & "): " & Rnd() & "<BR>" Next
' now display 100 random integers (1-100)
Response.Write "100 Random Integers<BR>" For I = 1 To 100 Response.Write "Random(" & I & "): " & CStr(Int(Rnd() * 100) + 1) & "<BR>" Next
|
 |

|