R
Richard
Hi I am trying to use this random number generator, I get a compile error:
Sub or function not defined.
' Random number selector program, chooses 6 numbers 1-49 without
duplication, used for UK lottery.
' Assumes form with button Command1 and six-label array Label1(0) to
Label1(5) without captions.
' ©Mike McGrath 1998 eMailto: (e-mail address removed)
Private Sub Command1_Click()
Dim Lottery(6) As Integer ' array to hold final selected
numbers
Dim nLucky As Integer ' variable to hold each random
selection
Dim nCount As Integer ' counter for number of
selections made
Dim nCheck As Integer ' counter for check on previous
selections
For nCount = 1 To 6 ' choose 6 numbers
Start: ' lets go (again)
Randomize ' random-seed the random
generator
nLucky = Int((49 * Rnd) + 1) ' pick random number from 1 to 49
For nCheck = 1 To 6
If nLucky = Lottery(nCheck) Then ' if seleced number has already
been picked...
GoTo Start ' go back and pick another
number.
End If
Next nCheck
Lottery(nCount) = nLucky ' store selection in array
Label1(nCount - 1) = Lottery(nCount) ' apply selection to labels (-1
for 0 to 5)
Next nCount
End Sub
the program highlites on this code: Label1(nCount - 1) =
also yellow arrow on this code: Private Sub Command1_Click()
Thanks for your help.
Sub or function not defined.
' Random number selector program, chooses 6 numbers 1-49 without
duplication, used for UK lottery.
' Assumes form with button Command1 and six-label array Label1(0) to
Label1(5) without captions.
' ©Mike McGrath 1998 eMailto: (e-mail address removed)
Private Sub Command1_Click()
Dim Lottery(6) As Integer ' array to hold final selected
numbers
Dim nLucky As Integer ' variable to hold each random
selection
Dim nCount As Integer ' counter for number of
selections made
Dim nCheck As Integer ' counter for check on previous
selections
For nCount = 1 To 6 ' choose 6 numbers
Start: ' lets go (again)
Randomize ' random-seed the random
generator
nLucky = Int((49 * Rnd) + 1) ' pick random number from 1 to 49
For nCheck = 1 To 6
If nLucky = Lottery(nCheck) Then ' if seleced number has already
been picked...
GoTo Start ' go back and pick another
number.
End If
Next nCheck
Lottery(nCount) = nLucky ' store selection in array
Label1(nCount - 1) = Lottery(nCount) ' apply selection to labels (-1
for 0 to 5)
Next nCount
End Sub
the program highlites on this code: Label1(nCount - 1) =
also yellow arrow on this code: Private Sub Command1_Click()
Thanks for your help.