Command Button Color Change on Click
Command Button Color Change on Click
(OP)
Me again,
I didn't want to bother you, but have tried and tried to get the command button to change color when I click it. Nothing is working... so I am asking, is it possible?
Private Sub Command1_Click()
counter = counter + 1
If counter = 1 Then
counter = counter - 1
End If
If counter = 1 Then
shpRed.BackColor = RGB(255, 0, 0)
shpAmber.BackColor = RGB(255, 255, 255)
shpGreen.BackColor = RGB(255, 255, 255)
ElseIf counter = 2 Then
shpAmber.BackColor = RGB(210, 100, 45)
ElseIf counter = 3 Then
shpGreen.BackColor = RGB(0, 140, 0)
shpRed.BackColor = RGB(255, 255, 255)
shpAmber.BackColor = RGB(255, 255, 255)
ElseIf counter = 4 Then
shpGreen.BackColor = RGB(255, 255, 255)
shpAmber.BackColor = RGB(210, 100, 45)
End If
End Sub
I didn't want to bother you, but have tried and tried to get the command button to change color when I click it. Nothing is working... so I am asking, is it possible?
Private Sub Command1_Click()
counter = counter + 1
If counter = 1 Then
counter = counter - 1
End If
If counter = 1 Then
shpRed.BackColor = RGB(255, 0, 0)
shpAmber.BackColor = RGB(255, 255, 255)
shpGreen.BackColor = RGB(255, 255, 255)
ElseIf counter = 2 Then
shpAmber.BackColor = RGB(210, 100, 45)
ElseIf counter = 3 Then
shpGreen.BackColor = RGB(0, 140, 0)
shpRed.BackColor = RGB(255, 255, 255)
shpAmber.BackColor = RGB(255, 255, 255)
ElseIf counter = 4 Then
shpGreen.BackColor = RGB(255, 255, 255)
shpAmber.BackColor = RGB(210, 100, 45)
End If
End Sub





RE: Command Button Color Change on Click
The code attached was for changing the color of the text of a couple of linked buttons called LDArm and Designate, but changing to BackColor instead of ForeColor changes the background instead of the text:
CODE
If LDArm.Tag = False Then
MsgBox ("You Are Arming Designator")
LDArm.Tag = True
LDArm.Caption = "LD Reset"
LDArm.BackColor = &H8000&
LDFlag.Text = "LD Armed"
LDFlag.BackColor = &HC0&
Designate.BackColor = &HC0&
Else
LDArm.Tag = False
LDArm.Caption = "LD Arm"
LDArm.BackColor = &HC0&
LDFlag.Text = "LD Idle"
LDFlag.BackColor = &H8000&
Designate.BackColor = &H8000&
End If
End Sub
Private Sub Designate_Click()
If LDArm.Tag = True Then MsgBox ("Firing Designator") Else MsgBox ("Designator Not Armed")
LDArm.Tag = False
LDFlag.Text = "LD Idle"
LDFlag.BackColor = &H8000&
Designate.BackColor = &H8000&
End Sub
TTFN
FAQ731-376: Eng-Tips.com Forum Policies