Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button Color Change on Click

Status
Not open for further replies.

Harley78

Electrical
May 8, 2007
77
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
 
Replies continue below

Recommended for you

Yes, it's possible, but I don't see anything in your code that's actually changing the color of the command button.

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:
Private Sub LDArm_Click()
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor