Dim counter As Integer
Dim firstNumber As Integer
Dim secondNumber As Integer
Dim higher As Integer
Dim lower As Integer
Dim score As Integer
Dim total As Integer
Dim win As Integer
Private Sub cmdGetNumber_Click()
If counter = 0 Then
lblWinner = "Game in Play"
Randomize
firstNumber = Int((99 * Rnd) + 1)
txtFirstNumber.Text = Str(firstNumber)
txtSecondNumber = ""
cheat: 'if win, restarts here
Randomize
secondNumber = Int((99 * Rnd) + 1)
counter = 1
If counter = 1 Then
optHigher.Visible = True
optLower.Visible = True
End If
End If
If counter = 1 Then
If (higher = 1) And (secondNumber > firstNumber) Then
GoTo cheat
ElseIf (higher = 1) And (firstNumber > secondNumber) Then
win = 0
lblWinner = "You lose"
txtSecondNumber.Text = Str(secondNumber)
score = -1
total = total + score
lblMessage = "Your Score is " + Str(total) & (" Play again?")
counter = 0
lower = 0
higher = 0
optHigher.Value = 0
optLower.Value = 0
optHigher.Visible = False
optLower.Visible = False
ElseIf (lower = 1) And (firstNumber > secondNumber) Then
GoTo cheat
ElseIf (lower = 1) And (secondNumber > firstNumber) Then
win = 0
lblWinner = "You Lose"
txtSecondNumber.Text = Str(secondNumber)
score = -1
total = total + score
lblMessage = "Your Score is " + Str(total) & (" Play again?")
counter = 0
lower = 0
higher = 0
optHigher.Value = 0
optLower.Value = 0
optHigher.Visible = False
optLower.Visible = False
ElseIf (firstNumber = secondNumber) Then
win = 0
lblWinner = "A Draw"
txtSecondNumber.Text = Str(secondNumber)
score = 0
total = total + score
lblMessage = "Your Score is " + Str(total) & (" Play again?")
counter = 0
lower = 0
higher = 0
optHigher.Value = 0
optLower.Value = 0
optHigher.Visible = False
optLower.Visible = False
End If
End If
If (total = -3) And (win = 0) Then
MsgBox "you're not very lucky", vbCritical, "Loser"
win = 1
ElseIf (total = -5) And (win = 0) Then
MsgBox "Give it up", vbCritical, "Loser"
win = 1
End If
End Sub
Private Sub optHigher_Click()
If counter = 1 Then
higher = 1
lower = 0
End If
End Sub
Private Sub optLower_Click()
If counter = 1 Then
higher = 0
lower = 1
End If
End Sub
Private Sub cmdExit_Click()
End
End Sub