如何在function里停止执行
function 里如何按下esc停止执行
Private Sub command1_Click()
run
end sub
Public Function run() As Long
On Error Resume Next
Dim I As Integer
Dim Script1 As String
Dim ScriptLen As Integer
Dim MousePos() As String
Dim MouseCurPos As POINTAPI
Dim ptime As Long
For I = 0 To List1.ListCount - 1 '从 ListBox 的第一个开始
Script1 = List1.List(I) '获得脚本
ScriptLen = Len(Script1) '获得脚本字符长度
Select Case Mid(Script1, 1, 2) '选择脚本字符前两个字符
Case "坐标"
Script1 = Mid(Script1, 4, ScriptLen - 3) '获得后面的字符
MousePos = Split(Script1, "-") '通过 - 来分割获得坐标,并放到 MousePos(数组)里面
SetCursorPos CLng(MousePos(0)), CLng(MousePos(1)) '设置鼠标位置
End Select
Next I
End Function
Private Sub command1_Click()
run
end sub
Public Function run() As Long
On Error Resume Next
Dim I As Integer
Dim Script1 As String
Dim ScriptLen As Integer
Dim MousePos() As String
Dim MouseCurPos As POINTAPI
Dim ptime As Long
bStop=false
For I = 0 To List1.ListCount - 1 '从 ListBox 的第一个开始
Script1 = List1.List(I) '获得脚本
ScriptLen = Len(Script1) '获得脚本字符长度
Select Case Mid(Script1, 1, 2) '选择脚本字符前两个字符
Case "坐标"
Script1 = Mid(Script1, 4, ScriptLen - 3) '获得后面的字符
MousePos = Split(Script1, "-") '通过 - 来分割获得坐标,并放到 MousePos(数组)里面
SetCursorPos CLng(MousePos(0)), CLng(MousePos(1)) '设置鼠标位置
End Select
doevents '使得有机会相应键盘或其它事件
if bStop then
exit for
end if
Next I
End Function