要使用API函数,检测键盘
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_ESCAPE = &H1B
Private Function CheckKey(lngKey As Long) As Boolean If GetAsyncKeyState(lngKey) Then CheckKey = True Else CheckKey = False End If End Function
sub 你的程序
'進入这个程序,运行一次这个程序
GetAsyncKeyState VK_ESCAPE
do
...........
..........
If CheckKey(VK_ESCAPE) = True Then '检测是不是按下了ESC键
........ Exit Sub End If
loop
.................
end sub
希望能帮到你的忙 |