VB Express 2011, first click changes button color, 2nd reverts.
VB Express 2011, first click changes button color, 2nd reverts.
(OP)
Hello, i am trying to create a little program for a game i play. I want to be able to change the color of one button (the one you click on) i have the changebackcolor, but i would like it to change back if it is clicked again
an example to get the point across (does not work)
so in short, i would like to click he button once, it changes the backcolor to red, if i click the button again, it will change it back to green, i would like to keep the code as short as possible as i have more than 26 buttons to do this to. thank you
an example to get the point across (does not work)
CODE
Private Sub btnengine1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnengine1.Click
Me.btnengine1.BackColor = Color.Red
if btnengine1.backcolor = color.red then
me.btnengine1.backcolor = color.green
end if
End Sub
Me.btnengine1.BackColor = Color.Red
if btnengine1.backcolor = color.red then
me.btnengine1.backcolor = color.green
end if
End Sub
RE: VB Express 2011, first click changes button color, 2nd reverts.
Private Sub btnengine1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnengine1.Click
if btnengine1.backcolor = color.red then
me.btnengine1.backcolor = color.green
else
me.btnengine1.backcolor=color.red
end if
End Sub
HTH, Dan