2015-06-28 29 views
-1

我目前在Visual Basic 6.0中玩耍,想知道當用戶按下某個特定鍵時,如何導致消息框或某些其他代碼出現/激活鍵盤如F1F2如何使按下一個鍵後出現一個消息框

+0

歡迎來到Stack Overflow!請花點時間仔細閱讀* *:[問] – Plutonix

+0

用戶按下哪個鍵? –

回答

3

使用Form_KeyDown(個人識別號碼,移位)方法在您的形式:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 

    If KeyCode = vbKeyF1 Then 
     //do something here if F1 key is pressed 
     //or call a method 


    End If 
End Sub 

此外,您還可能需要設置KeyPreview屬性爲true的形式。

相關問題