Quantcast
Viewing all articles
Browse latest Browse all 42307

VS 2010 How do i do this: If textbox1 value = good Then ... (comparing values from txtbox)

Ok so I am doing some newbie style error checking stuff to keep a program running. Because I am still learning the basics. But in these examples I am simply trying to look at the text value of TextBox9.Text & depending on its current value it will either Add 1 to counter & continue....or Msgbox me, clear the listbox & clear the listbox count. So now when my program successfully does an action, the next line in code will be... TextBox9.Text = ("good"). Later in the code it will do TextBox9.Text = ("bad"). Then I will have a timer checking every "X" minutes for the text currently set in TextBox9.Text..that way if an hour later it still says "bad" i could make it start up again etc.

Which one of these 2 examples should I be using (One if just IF .... the other uses IF & ElseIF)

Code:

        'Example #1 (using just IF's)
 Private Sub Timer13_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer13.Tick
        If TextBox9.Text = ("good") Then
            counter += 1
            Continue(counter)
            If TextBox9.Text = ("bad") Then
                MsgBox("Starting over!")
                ListBox1.Items.Clear()
                counter = 0
                StartOver(counter)
            End If
        End If
               
    End Sub
       
        'Example #2  (using if & elseif)
       
    Private Sub Timer13_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer13.Tick

        If TextBox9.Text = ("good") Then
            counter += 1
            Continue(counter)
        ElseIf TextBox9.Text = ("bad") Then
            MsgBox("Starting over!")
            ListBox1.Items.Clear()
            counter = 0
            StartOver(counter)
        Else
        End If
               
    End Sub

Or is there a better/simpler way to write this out/have it perform as I want it to
Thanks! I know this is simple stuff for most of you so please hold back your laughter! LOL

Viewing all articles
Browse latest Browse all 42307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>