VB 2010 - Action based on button text
Posted on 2011-10-26
I originally learned VB using VB6 and I am now learning VB 2010 and I learned a trick during VB6 class that I can't seem to repeat or remember the correct format. I have button1 with the text "ENTER" and when I click the button I want an action to occur, like the background changing color. Also, when the button is clicked I want the text to change on the button to "FLIP." Then when the user clicks the button it executes a different action because the text in the button is "FLIP" not "ENTER." The code below shows you what I am trying to do but it will not go work. I basically want one button to do two things and I used to be able to do it but I can't remember how.
If Button1.Text = "ENTER" Then
Me.BackColor = Color.Brown
Button1.Text = "FLIP"
ElseIf Button1.Text = "FLIP" Then
Me.BackColor = Color.Gold
Button1.Text = "ENTER"