I am creating a random number guessing game. I have 6 options. 3 Game playing levels and 3 timer levels.
I have my form display with 6 radio buttons:
radRookie
radVeteran
radPro
radThirty
radFourtyFive
radSixty
You select your level and time.
Then you have a text box to enter your guess, then click guess.
I want to display an image above or below the text box to guess higher or guess lower.
I can get the images hidden until button click, but only one image displays and doesn't work properly.
I also cannot get the darn timer to work and count down while guessing. Any help please!?!
Public Class Form1
Dim intGuess As Integer
Dim aRandom As New Random
Dim holdNumber As Integer
Dim timercount As Integer
Private Sub radRookie_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radRookie.CheckedChanged
holdNumber = aRandom.Next(0, 10)
End Sub
Private Sub radVeteran_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radVeteran.CheckedChanged
holdNumber = aRandom.Next(0, 100)
End Sub
Private Sub radPro_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radPro.CheckedChanged
holdNumber = aRandom.Next(0, 1000)
End Sub
Private Sub btnGuess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuess.Click
If Integer.TryParse(txtNumber.Text, intGuess) Then
If intGuess > -1 Then
If radRookie.Checked = True Then
If txtNumber.Text = holdNumber Then
imgHigher.Visible = False
imgLower.Visible = False
MessageBox.Show("You Win! The Number was " & holdNumber)
ElseIf txtNumber.Text < holdNumber Then
imgHigher.Visible = True
ElseIf txtNumber.Text > holdNumber Then
imgHigher.Visible = True
End If
ElseIf radVeteran.Checked = True Then
If txtNumber.Text = holdNumber Then
imgHigher.Visible = False
imgLower.Visible = False
MessageBox.Show("You Win! The Number was " & holdNumber)
ElseIf txtNumber.Text < holdNumber Then
imgHigher.Visible = True
ElseIf txtNumber.Text > holdNumber Then
imgHigher.Visible = True
End If
ElseIf radPro.Checked = True Then
If txtNumber.Text = holdNumber Then
imgHigher.Visible = False
imgLower.Visible = False
MessageBox.Show("You Win! The Number was " & holdNumber)
ElseIf txtNumber.Text < holdNumber Then
imgHigher.Visible = True
ElseIf txtNumber.Text > holdNumber Then
imgHigher.Visible = True
End If
End If
Else
MessageBox.Show("Must enter a Valid Guess!")
End If
End If
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
radRookie.Checked = False
radVeteran.Checked = False
radPro.Checked = False
radThirty.Checked = False
radFourtyFive.Checked = False
radSixty.Checked = False
lblTimeRemain.Text = String.Empty
txtNumber.Clear()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If radThirty.Checked = True Then
Timer1.Interval = 1000
Timer1.Enabled = True
timercount = 30
lblTimeRemain.Text = timercount.ToString()
If timercount = 0 Then
Timer1.Enabled = False
lblTimeRemain.Text = "Done"
Else
timercount -= 1
End If
ElseIf radFourtyFive.Checked = True Then
Timer1.Interval = 1000
Timer1.Enabled = True
timercount = 45
lblTimeRemain.Text = timercount.ToString()
If timercount = 0 Then
Timer1.Enabled = False
lblTimeRemain.Text = "Done"
Else
timercount -= 1
End If
ElseIf radSixty.Checked = True Then
Timer1.Interval = 1000
Timer1.Enabled = True
timercount = 60
lblTimeRemain.Text = timercount.ToString()
If timercount = 0 Then
Timer1.Enabled = False
lblTimeRemain.Text = "Done"
Else
timercount -= 1
End If
End If
End Sub
End Class
Here is my gui