我在vb6中进行编码,为了好玩,我会尝试使用按键事件来使事情发生变化。我快速意识到,非常有限数量的键会响应按键事件。我想使用箭头键,但似乎虽然有保留命令(VBKeyUp
,VBKeyDown
,VBKeyRight
,VBKeyLeft
),但他们根本不做任何事情。对此有解释还是他们没有支持?代码即时使用如下。
Private Sub ListView67_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyUp Then
Command1_Click
End If
If KeyAscii = vbKeyDown Then
Command4_Click
End If
If KeyAscii = vbKeyRight Then
Command2_Click
End If
If KeyAscii = vbKeyLeft Then
Command3_Click
End If
End Sub
答案 0 :(得分:2)
使用KeyDown事件而不是KeyPress
Private Sub ListView67_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
Command1_Click
End If
If KeyCode = vbKeyDown Then
Command4_Click
End If
If KeyCode = vbKeyRight Then
Command2_Click
End If
If KeyCode = vbKeyLeft Then
Command3_Click
End If
End Sub