As I was testing the game I noticed that when you try to guess another number for the second time and you guessed it right the "Game over, the correct guess is __" messagebox.show appears. Can someone explain what is wrong with this?

Public Class SuperAwesomeGuessingGame
    Dim ranNum As Integer = 0
    Dim intCounter As Integer = 3

    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
        txtbxEnterNum.Clear()
        ranNum = 0
    End Sub

    Private Sub btnPlay_Click(sender As System.Object, e As System.EventArgs) Handles btnPlay.Click

        Dim intEnterNum As Integer = 0 ' Declaring intEnterNum as an integer
        Try
            intEnterNum = CInt(txtbxEnterNum.Text) 'Using the convertion type Cint
            intCounter -= 1


            If intCounter > 0 Then

                If (intEnterNum <> ranNum) Then
                    MessageBox.Show("Wrong guess again. You have " & intCounter & " chances left.")
                Else
                    If MessageBox.Show("Correct! Do you wish to restart?", "Please Confirm Action", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                        txtbxEnterNum.Clear()
                        ranNum = 0
                    ElseIf Windows.Forms.DialogResult.No Then
                        Me.Close()
                    End If
                End If

            Else
                If MessageBox.Show("Game Over", "Try Again", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    txtbxEnterNum.Clear()
                ElseIf Windows.Forms.DialogResult.No Then
                    Me.Close()

                End If
            End If
        Catch e1 As InvalidCastException
            MessageBox.Show("Please Enter a Number ", "Illegal Value Entered")
            txtbxEnterNum.Clear()
            ranNum = 0

        Catch e2 As OverflowException
            MessageBox.Show("You Entered A Large Number")
            txtbxEnterNum.Clear()
            ranNum = 0
        Catch e3 As Exception
            MessageBox.Show("An error has occured. PLease try again.")
            txtbxEnterNum.Clear()
            ranNum = 0


        End Try


    End Sub

    Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click
        Me.Close()

    End Sub

    Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
        intCounter = 3
        ranNum = CInt(Rnd() * 10)
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        MessageBox.Show("Welcome to THE SUPER AWESOME GUESSING GAME! \m/", "The Super Awesome Guessing Game!")
    End Sub
End Class

If you are receiving the prompt above then you have more problems than that code. ^_^

I do not see the message box which you are talking of.

Is this code snippet the full code? (I am assuming it is because of the class tags)

Yeah this is the entire code. if you try and run it you will see what I am talking about. I'll appreciate any type of help.

I copied the code into a blank project and created what I assume to be the form and I can see part of your problem is that you allow the user to press the play button when the counter is already to zero.

You will need to disable the play button when the counter hits zero.

For example:

If intCounter > 0 Then
    intCounter -= 1

    If intEnterNum <> ranNum Then
        If intCounter > 0 Then
            MessageBox.Show("Wrong guess again. You have " & intCounter & " chances left.")
        Else
            txtbxEnterNum.Enabled = False
            If MessageBox.Show("Game Over", "Try Again", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then btnReset.PerformClick()
        End If
   Else
       If MessageBox.Show("Correct! Do you wish to restart?", "Please Confirm Action", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then btnReset.PerformClick()
   End If
End If

Now change your btnReset_Click sub to look something like:

Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
    txtbxEnterNum.Clear()
    txtbxEnterNum.Enabled = True
    ranNum = 0
    intCounter = 3
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.