VB FOR循环如何实现按ESC退出循环?
Sub xh()Dim i As Integer
For i = 1 To 100
Call xgwz
Next i
End Sub
这个宏(无窗体)应该修改成怎样才可以实现在循环中按ESC退出循环?
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
页:
[1]