按指定键,光标在哪里呢?
这里有段,鼠标问题解决了
Dim check1 As Boolean
Dim check2 As Boolean
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
If check2 = True Then
Exit Sub
End If
Call fun1
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyAscii = 13 Then '13是回车
check1 = True
Else
check1 = False
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '13是回车
check1 = True
Else
check1 = False
End If
End Sub
Private Sub Form_Load()
check2 = False
End Sub
Private Sub fun1()
Dim i As Long
check2 = True
For i = 1 To 200
If check1 = True Then 'check1作为全局变量
Exit For
End If
Sleep (100)
Debug.Print CStr(i)
Next i
check2 = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '1是左键
check1 = True
Else
check1 = False
End If
End Sub