You need to play with the "X" and Y" variables and their poition to get the best results.
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If X > 5 Xor Y > 2 And X < CommandButton1.Width - 5 Xor Y < CommandButton1.Height - 2 Then
CommandButton1.BackColor = vbRed
Else
CommandButton1.BackColor = vbGreen
End If
End Sub
Bookmarks