×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Command Button Color Change on Click

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

RE: Command Button Color Change on Click

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: Eng-Tips.com Forum Policies

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources