Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case vbKeyUp Label1.Caption = "UP" Case vbKeyDown Label1.Caption = "Down" Case vbKeyLeft Label1.Caption = "Left" Case vbKeyRight Label1.Caption = "Right" Case Else End Select End Sub
Private Sub Cmd_Up_Click() Label1.Caption = "UP" Text1.SetFocus End Sub
Private Sub Cmd_Down_Click() Label1.Caption = "Down" Text1.SetFocus End Sub
Private Sub Cmd_Left_Click() Label1.Caption = "Left" Text1.SetFocus End Sub
Private Sub Cmd_Right_Click() Label1.Caption = "Right" Text1.SetFocus End Sub
[解决办法]
随手做个测试, 新建工程,窗体代码如下:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Me.Caption = KeyCode End Sub