|
How to generate Random numbers using ASP
(Random Numbers) are easy to generate in ASP. I will show you how to generate a random number between your Min value and your Max value. Random Numbers are not really random. They are a from a PRNG (Psudo Random Number Generator). A PRNG has a random number seed that has a finite length, thus after a long period of time the random numbers will start forming patterns.
Issues: You must call the Randomize statement before the RND command.
Logic Flow:
Call Randomize before using the RND Command.
Randomize
Now specify your Min and Max Limits for the random number.
Random_Number_Min = 2
Random_Number_Max = 10
Use the RND command to generate a Random Number between your Min and Max.
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)
Output your Random Number to the Client Browser.
Response.Write "Random Number = " & Random_Number & "<br>"
|
|