添加快捷鍵 -------------------------------------------------------------------------------------------------------------------------------------------------------- 需要vb api函數: getasynckeystate ←判斷函數調用時指定虛擬鍵的狀態 -------------------------------------------------------------------------------------------------------------------------------------------------------- 相關api聲明: getasynckeystate ↓ private declare function getasynckeystate lib "user32" (byval vkey as long) as integer private function myhotkey(vkeycode) as boolean -------------------------------------------------------------------------------------------------------------------------------------------------------- 需要的控件:timer(interval不為空) -------------------------------------------------------------------------------------------------------------------------------------------------------- 代碼: 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 -------------------------------------------------------------------------------------------------------------------------------------------------------- 其它方法: 比如按下"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