VB判断键盘输入
下图表示的是键盘各按键的KeyCode值:
到这里,我们在KeyDown或KeyUp等事件的代码里用
If KeyCode="20" Then ^^^^^^^^
或 If KeyCode=20 Then ^^^^^^^^
语句就可以判断键盘输入了。
VB中还有一些特殊按键:
Private Sub Form_KeyDown(KeyCode As Integer,ShIft As Integer)
If KeyCode=vbKeyLeft Then ^^^^^^^^
If KeyCode=vbKeyRight Then ^^^^^^^
If KeyCode=vbKeyDown Then ^^^^^^^
If KeyCode=vbKeyUp Then ^^^^^^^
If KeyCode=vbKeySpace Then ^^^^^^^
If KeyCode=vbKeyEscape Then ^^^^^^^
If KeyCode=vbKeyTab Then ^^^^^^^
If KeyCode = vbKeyNumlock Then ^^^^^^^
If KeyCode = vbKeyFn Then ^^^^^^^
If KeyCode = vbKeyPause Then ^^^^^^^
If KeyCode = vbKeyPageDown Then ^^^^^^^
If KeyCode = vbKeyPageUp T
下图表示的是键盘各按键的KeyCode值:
![](http://hi.csdn.net/attachment/201107/20/0_131113451522I0.gif)
到这里,我们在KeyDown或KeyUp等事件的代码里用
If KeyCode="20" Then ^^^^^^^^
或 If KeyCode=20 Then ^^^^^^^^
语句就可以判断键盘输入了。
VB中还有一些特殊按键:
Private Sub Form_KeyDown(KeyCode As Integer,ShIft As Integer)
If KeyCode=vbKeyLeft Then ^^^^^^^^
If KeyCode=vbKeyRight Then ^^^^^^^
If KeyCode=vbKeyDown Then ^^^^^^^
If KeyCode=vbKeyUp Then ^^^^^^^
If KeyCode=vbKeySpace Then ^^^^^^^
If KeyCode=vbKeyEscape Then ^^^^^^^
If KeyCode=vbKeyTab Then ^^^^^^^
If KeyCode = vbKeyNumlock Then ^^^^^^^
If KeyCode = vbKeyFn Then ^^^^^^^
If KeyCode = vbKeyPause Then ^^^^^^^
If KeyCode = vbKeyPageDown Then ^^^^^^^
If KeyCode = vbKeyPageUp T