If in VBA, use the pre-defined color constants or, if not available, define
your own.
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If CommandButton1.BackColor <> vbRed Then
CommandButton1.BackColor = vbRed
CommandButton1.ForeColor = vbBlack
Else
CommandButton1.BackColor = vbBlack
CommandButton1.ForeColor = vbRed
End If
End Sub
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Const clrRed = &HFF&
Const clrBlack = &H80000012
If CommandButton1.BackColor <> clrRed Then
CommandButton1.BackColor = clrRed
CommandButton1.ForeColor = clrBlack
Else
CommandButton1.BackColor = clrBlack
CommandButton1.ForeColor = clrRed
End If
End Sub
You can define constants in a procedure, or in the declaration section (at
the top) of a module, either private or public, depending on the scope (how
widely available among your code) that you need.