|
 |
asptoday_discuss thread: Random Integer
Message #1 by "Tan Chye Ting" <chyeting18@h...> on Tue, 15 Jan 2002 07:27:24
|
|
how do i generate ramdom integers in ASP?I'm trying to using Random number
to control an array...please reply ASAP
Message #2 by "Tripp Bishop" <dyne_erg@y...> on Tue, 15 Jan 2002 15:17:03
|
|
> how do i generate ramdom integers in ASP?I'm trying to using Random
number
> to control an array...please reply ASAP
Do something like this...
The function Rnd will return a number between 0 and 1. To increase this to
a range of integers, multiply by the upper bound (for example,
Int(10 * Rnd) would create a number between 0 and 10). If you're going to
be generating random numbers in a loop then you'll need to reseed on every
iteration. To do this, use the Randomize key word, otherwise
you'll "generate" the same number over and over.
--Tripp
Message #3 by "Rich McQuaid" <remcq@m...> on Wed, 16 Jan 2002 07:47:05 -0500
|
|
I found this in help. I haven't tried it myself
Set Tools = Server.CreateObject("MSWC.Tools")
<% = Tools.Random %> will display a random integer between -32768 to
32767. For example, -13067.
<% = ( Abs( Tools.Random ) ) %> will display a positive random integer.
For example, 23054.
<% = ( Abs( Tools.Random ) ) Mod 100 %> will display a random integer
between 0 and 99. For example, 63.
Good luck!
-----Original Message-----
From: Tan Chye Ting [mailto:chyeting18@h...]
Sent: Tuesday, January 15, 2002 7:27 AM
To: ASPToday Discuss
Subject: [asptoday_discuss] Random Integer
how do i generate ramdom integers in ASP?I'm trying to using Random
number
to control an array...please reply ASAP
|
|
 |