3.以下为快捷键例子.比如按下"ctrl+A"就退出!
'可以设置Form的KeyPreview属性为True,然后在Form_KeyDown事件中添加代码: 
 Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
If KeyCode = Asc("A") And Shift = vbCtrlMask Then unload me '如果ctrl+A键被按下就退出
 End Sub 


例二:
在Form中加入
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = (GetAsyncKeyState(vKeyCode) < 0)
 End Function
'然后在循环中或Timer的Timer事件中检测:
Private Sub Timer1_Timer()
If MyHotKey(vbKeyA) And vbKeyControl Then 'ctrl+A
End '关闭
End If
'其中vbkeyA是键盘〃A〃的常数,其他键可按F1查得。
End Sub

相关文章:

  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-04-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
相关资源
相似解决方案