Hiện Key Code

đăng 20:25, 27 thg 3, 2012 bởi Hai Yen   [ đã cập nhật 07:33, 16 thg 9, 2014 ]

Sự kiện keydown của form, chặn các phím bằng case, nếu là phím nào thì cho thực thi đoạn code đó:

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

Select Case KeyCode

Case "8"

MsgBox "Backspace Keyis " & KeyCode

 

Case "9"

MsgBox "Tap Key is " & KeyCode

 

Case "12"

MsgBox "Clear Key is " & KeyCode

 

Case "13"

MsgBox "Enter Key is " & KeyCode

 

Case "16"

MsgBox "Shift Key is " & KeyCode

 

Case "17"

MsgBox "Control Key is " & KeyCode

 

Case "27"

MsgBox "Esc Key is " & KeyCode

 

Case "32"

MsgBox "SpaceBar Key is " & KeyCode

 

Case "112"

MsgBox "F1 Key is " & KeyCode

 

Case "113"

MsgBox "F2 Key is " & KeyCode

 

Case "114"

MsgBox "F3 Key is " & KeyCode

 

Case "115"

MsgBox "F4 Key is " & KeyCode

 

Case "116"

MsgBox "F5 Key is " & KeyCode

 

Case "117"

MsgBox "F6 Key is " & KeyCode

 

Case "118"

MsgBox "F7 Key is " & KeyCode

 

Case "119"

MsgBox "F8 Key is " & KeyCode

 

Case "120"

MsgBox "F9 Key is " & KeyCode

 

Case "121"

MsgBox "F10 Key is " & KeyCode

 

Case "122"

MsgBox "F11 Key is " & KeyCode

 

Case "123"

MsgBox "F12 Key is " & KeyCode

 

Case Else

MsgBox "you is press " & KeyCode

 

End Select

 

End Sub

Comments