I have created a button (called StartComms) on a form, and want the button text to change each time it is pressed. The code does NOT work if I just step through it, because although StartComms.Text does equal "Start Logging", the IF statement does not execute. If I force the execution of the second line after the IF as marked, the the code will work and continue to work perfectly until the program is re-opened !
What am I doing wrong ?
Richard
Private Sub StartComms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartComms.Click
If StartComms.Text = "Start Logging" Then
StartComms.Text = "Stop Logging" 'force code here
StartComms.FlatStyle = FlatStyle.Flat
StartComms.BackColor = BackColor.Lime
ElseIf StartComms.Text = "Stop Logging" Then
StartComms.Text = "Start Logging"
StartComms.FlatStyle = FlatStyle.Standard
StartComms.BackColor = System.Drawing.SystemColors.Control
End If
End Sub
What am I doing wrong ?
Richard
Private Sub StartComms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartComms.Click
If StartComms.Text = "Start Logging" Then
StartComms.Text = "Stop Logging" 'force code here
StartComms.FlatStyle = FlatStyle.Flat
StartComms.BackColor = BackColor.Lime
ElseIf StartComms.Text = "Stop Logging" Then
StartComms.Text = "Start Logging"
StartComms.FlatStyle = FlatStyle.Standard
StartComms.BackColor = System.Drawing.SystemColors.Control
End If
End Sub