'判断 Text1 当前颜色,然后赋值
Private Sub Command1_Click()
If Text1.BackColor = vbRed then
Text1.BackColor = vbGreen
Else
Text1.BackColor = vbRed
End If
End Sub
'或者也可以这样写,意思一样
Private Sub Command1_Click()
Text1.BackColor = IIf( Text1.BackColor = vbRed , vbGreen , vbRed )
End Sub