嗯,测试了下,主要是有24个系统色导致的颜色错误,把这24个颜色单独考虑就行了,如下代码可得到粉红色和白色之间的变换:
Private Sub Text1_Click() Dim a As Long a = Text1.BackColor Xor &HCC10CC'&HCC10CC可以变换为其他数字,只要在24位色范围内都行,及>&H0<&HFFFFFF If Not (a > &H80000019 And a < &H80000000) Then a = a And &HFFFFFF If a > 0 And a < 24 Then a = a Or &H80000000 Text1.BackColor = a
End Sub