Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_ESCAPE = &H1B
Private Const VK_RButton = &H2
GetAsyncKeyState VK_ESCAPE '判断前先调用一次
Do
If CheckKey(VK_ESCAPE) = True Then '如果按下了ESC键或鼠标右键,则退出
Exit Sub
End If
'此处处理你的事情的代码
If CheckKey(VK_ESCAPE) Then '如果按下了ESC键或鼠标右键,则退出
Exit Sub
End If
Loop