labels need to be clicked twiceto change color?????

So basically, I have figured out how to change the buttons text color if they are clicked individually(used to be labels I will change them back)...... But it seems that all but the first button need to be clicked two times to start there changing of colors

Private Sub frmJaime_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim MyButt() As Button = {btnA, btnB, btnC, btnD, btnE, btnF, btnG, _
btnH, btnI, btnJ, btnK, btnL, btnM, btnN, btnO, btnP, btnQ, btnR, btnS, btnT, _
btnU, btnV, btnW, btnX, btnY, btnZ}

AddHandler MyButt(0).Click, AddressOf ColorSwitch
AddHandler MyButt(1).Click, AddressOf ColorSwitch
AddHandler MyButt(2).Click, AddressOf ColorSwitch
AddHandler MyButt(3).Click, AddressOf ColorSwitch
end sub
Private Sub ColorSwitch(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim btn As Button = DirectCast(sender, Button)
Dim i As Integer
If btn.ForeColor.Equals(Color.Black) Then
btn.ForeColor = Drawing.Color.Gray
ElseIf btn.ForeColor.Equals(Color.Gray) Then
btn.ForeColor = Drawing.Color.Green
Else : btn.ForeColor = Drawing.Color.Black
End If
End Sub

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!