Results 1 to 3 of 3

Thread: What's wrong with this code? - Beginner

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2014
    Posts
    21

    Question What's wrong with this code? - Beginner

    Hello VBForums.

    Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If TextBox1.Text = TextBox2.Text Then
                MsgBox("The scores have Evened!")
            End If
            If TextBox1.Text > TextBox2.Text Then
                MsgBox("Orange team in the lead!")
            End If
            If TextBox1.Text < TextBox2.Text Then
                MsgBox("Blue Team in the lead!")
            End If
        End Sub
    I want this code to make MsgBox's that appear every time the scores in the MsgBox's apply to these rules. So when the TextBox2 (Team 2)'s score overtakes Team one it will display the Message.

    The Code I have in there currently just makes the first MsgBox "The scores have Evened!" it does it once when I start the program then doesn't do it again.

    I don't want it to repeat the code every time to score is updated such as score 10-15 then 10-17 "Blue Team in the lead!"
    So it only displays the MsgBox's when the score evens or when one team overtakes.

    Thanks.

  2. #2
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: What's wrong with this code? - Beginner

    Read my reply in this thread again. You are putting the code in the WRONG SUB!

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: What's wrong with this code? - Beginner

    Right, that doesn't belong in Form Load, it belongs elsewhere, and I think Espanolita covered the options in the other thread. So, this is just a second opinion.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width