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
Dim cheatcounter As Integer
Private Sub cmdGetNumber_Click()
If counter = 0 Then
counter = 1
lblWinner = "Game in Play"
optHigher.Visible = True
optLower.Visible = True
Randomize
firstNumber = Int((99 * Rnd) + 1)
txtFirstNumber.Text = Str(firstNumber)
txtSecondNumber = ""
End If 'end of first number
If counter = 1 Then 'start second number
Cheat:
cheatcounter = cheatcounter + 1 'starts at one and increments
If cheatcounter > 1 Then 'resets on 2
cheatcounter = 0 'has values zero and one
End If
Randomize
secondNumber = Int((99 * Rnd) + 1)
If (higher = 1) And (secondNumber > firstNumber) Then
If cheatcounter = 0 Then 'cheats on zero
GoTo Cheat
End If
win = 1
lblWinner.Caption = "You Win !!!"
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 (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
If cheatcounter = 0 Then 'cheats on zero
GoTo Cheat
End If
win = 1
lblWinner = "You Win"
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 (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 'ready for new game
lower = 0
higher = 0
optHigher.Value = 0
optLower.Value = 0
optHigher.Visible = False
optLower.Visible = False
End If
End If 'end of second number
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