A1VBCode Forums

simple question


http://www.a1vbcode.com/vbforums/Topic11772.aspx

By Mad Monkey - 5/28/2005

Hello All I have very simple question and Im making very simple game:

 

Say i have random number generator with Select Case in a loop

counter = 0

Do

number = Int(rnd * 20) + 1

Select case number

Case 1

.....

Case 2

...etc

counter = counter + 1

Loop While counter < 10

So I have the same case looping 10 times, but the thing I want is that when the case was selected for it never to be selected in the next loops? Is there any simple way to do that?    P.S Im realy new to vb6 so try not to confuse me

By pso - 6/9/2005

Do you mean not to repeat the number that is generated?

Private Sub Command1_Click()
Dim counter As Integer, oldnum As Integer, number As Integer
Randomize
counter = 0
oldnum = 0
Do

number = Int(Rnd * 20) + 1
If oldnum = number Then GoTo nextNum
Select Case number

Case Else
Text2 = Text2 & number & vbCrLf
End Select
counter = counter + 1
oldnum = number
nextNum:
Loop While counter < 10
End Sub