tomanderson12
Member
- Joined
- Jan 21, 2008
- Sythe Gold
- 0
- Messages
- 53
I need some help, iv been working on this lottery 'game' if you will, I had a problem a while back with numbers generating but making sure they dont generate the same, that was fixed now im trying to compare the users numbers to the generated if they are correct then a label changes to how ever many matched i have this code
That is all the code from there you should be able to figure out the names etc
Help on how to get the caption to change will be useful
Code:
Private Sub Text2_Change(Index As Integer)
End Sub
Private Sub cmdRun_Click()
'Dimension the variables used in the programme
Dim intNumber As Integer
Dim arrNumber(0 To 5) As Integer
Dim intCount As Integer
Dim intCheck As Integer
Dim count3 As Integer
Dim temp As Integer
Dim count As Integer
'*******************************************************************
'Sets Count
For intCount = 0 To (txtMachine.count - 1)
Randomize
intNumber = Int(Rnd * 49) + 1 ' Random number 1 to 49
arrNumber(intCount) = intNumber
If intCount > 0 Then
ReCheck:
For intCheck = 0 To intCount - 1
If intNumber = arrNumber(intCheck) Then
intNumber = Int(Rnd * 49) + 1
arrNumber(intCount) = intNumber
temp = 0
GoTo ReCheck
End If
Next intCheck
End If
txtMachine(intCount).Text = intNumber
Next intCount
If txtUser(Index) = txtMachine(Index).Text Then
lblMatch.Caption = lblMatch.Caption + 1
End If
'*******************************************************************
txtUser(0).Enabled = False
txtUser(1).Enabled = False
txtUser(2).Enabled = False
txtUser(3).Enabled = False
txtUser(4).Enabled = False
txtUser(5).Enabled = False
'*******************************************************************
If Val(lblMatch.Caption) < 3 Then
MsgBox ("You have won nothing")
lblMatch.Caption = "0"
End If
If Val(lblMatch.Caption) = 3 Then
MsgBox ("You have won £5")
lblMatch.Caption = "0"
End If
If Val(lblMatch.Caption) = 4 Then
MsgBox ("You have won £15")
lblMatch.Caption = "0"
End If
If Val(lblMatch.Caption) = 5 Then
MsgBox ("You have won £50")
lblMatch.Caption = "0"
End If
If Val(lblMatch.Caption) = 6 Then
MsgBox ("You have won £250")
lblMatch.Caption = "0"
End If
End Sub
Private Sub Form_Activate()
'Sets the focus for the text boxes when form loads
txtUser(Index).SetFocus
End Sub
Private Sub txtUser_Change(Index As Integer)
'Makes sure that zeros are not entered
'If txtUser(Index).Text < 1 Then
' MsgBox ("You need to choose a number greater than Zero")
'End If
'Makes sure that all the users numbers are entered
If txtUser(Index).Text = "" Then
MsgBox ("You must enter your chosen numbers to see if you have won")
cmdRun.Enabled = False
Else
cmdRun.Enabled = True
End If
'checks to see if the number entered is between 1 and 49
If Val(txtUser(Index).Text) > 49 Then
MsgBox ("Please Enter a Number Between 1 and 49")
txtUser(Index).BackColor = &H8080FF
'Clears the text box ready for the next number
txtUser(Index).Text = ""
Else
txtUser(Index).BackColor = &H80000005
End If
'If lblCheck.Caption = "6" Then
' Me.cmdRun.Enabled = True
'End If
End Sub
Private Sub txtUser_LostFocus(Index As Integer)
If Index > 0 Then
If txtUser(Index) = txtUser(Index - 1) Then
MsgBox ("Sorry but you have two of the same numbers")
txtUser(Index).BackColor = &H8080FF
End If
End If
End Sub
Help on how to get the caption to change will be useful

