|
-
Feb 16th, 2010, 04:47 PM
#1
Thread Starter
Member
how to make a random array not generate a number it has already generated
Hi
The thing is, im trying to make a random array of three numbers. Now, i've made the random array but i need it to not generate any numbers that it has already generated. for example:
1 2 3, not 1,1,2 or 1,2,1.
heres some code i made up to try and do it:
Code:
'generates three random numbers
Randomize
picdisplay1.Cls
picdisplay2.Cls
picdisplay3.Cls
lott_num(1) = Int((Rnd * 5) + 1)
lott_num(2) = Int((Rnd * 5) + 1)
lott_num(3) = Int((Rnd * 5) + 1)
If lott_num(1) = lott_num(2) Or lott_num(3) Then
lott_num(1) = Int((Rnd * 5) + 1)
Else
If lott_num(2) = lott_num(3) Then
lott_num(2) = Int((Rnd * 5) + 1)
End If
End If
picdisplay1.Print (lott_num(1))
picdisplay2.Print (lott_num(2))
picdisplay3.Print (lott_num(3))
if this is the right method and its some mistake ive made then i would appreciate it being pointed out, however, if there is a more elegant method, then im open to suggestions.
Thanks! 
Cal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|