Generate 3 random numbers betwen 1 and 20

Thread: Generate 3 random numbers betwen 1 and 20

1. Nuno Guest

Generate 3 random numbers betwen 1 and 20

Hi<BR><BR>How am I able to generate 3 random numbers betwen 1 and 20 an ensure that they are always diferents ?<BR><BR>Thanks<BR><BR>Nuno

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

RE: Generate 3 random numbers betwen 1 and 20

use the ramdomise ie the rnd function<BR><BR>Int((20 - 1 + 1) * Rnd + 1) this should give you the numbers between 1 and 20<BR><BR>now you cannot always guarentee that they are always differnet for that use a dictionary object ro save them into an array and check each time a number is generated if it is unique<BR><BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
1,944

RE: Generate 3 random numbers betwen 1 and 20

i&#039m not sure whether u can avoid repeating the same flow of numbers.<BR> Randomize<BR> Min = 2<BR> Max = 10<BR>for i=1 to 3<BR> Number = Int(((Max-Min+1) * Rnd) + Min)<BR> Response.Write "Random Number = " & Number & "<BR>" <BR>next

4. Senior Member
Join Date
Dec 1969
Posts
1,944

RE: Generate 3 random numbers betwen 1 and 20

i&#039m not sure whether u can avoid repeating the same flow of numbers.<BR> Randomize<BR> Min = 1<BR> Max = 20<BR>for i=1 to 3<BR> Number = Int(((Max-Min+1) * Rnd) + Min)<BR> Response.Write "Random Number = " & Number & "<BR>" <BR>next

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•