在KeyDown事件里进行控制:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Msgbox "Press Enter"
ElseIf KeyCode = 32 Then
Msgbox "Press Space"
End If
End SubPrivate Sub Form_Load()
Me.KeyPreview = True
......
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Msgbox "Press Enter"
ElseIf KeyCode = 32 Then
Msgbox "Press Space"
End If
End SubPrivate Sub Form_Load()
Me.KeyPreview = True
......
End Sub
If KeyCode = 13 Then
Msgbox "Press Enter"
call Command2_Click
ElseIf KeyCode = 32 Then
Msgbox "Press Space"
call SubName
End If
End SubPrivate Sub Form_Load()
Me.KeyPreview = True
......