打扰了。我已经阅读了3个小时,但仍无法解决。鼠标单击按钮后,如何制作表单以再次响应KeyDown事件。首先,它会响应键盘上的字母“ n”。但是,如果用户选择单击按钮,则Keydown事件将不再触发。 我尝试调用将我的表单设置为等待按键事件的代码,但是它不起作用。
Private Sub Btn_NextStudent_Click()
MsgBox "You clicked the button"
'GETS READY FOR KEYDOWN EVENTS AGAIN (*****THIS DOESN'T WORK*****)
TabstopFocusOnClick
End Sub
Private Sub UserForm_Initialize()
'PREPARAR CONTROLES PARA LOS EVENTOS KEYDOWN
TabstopFocusOnClick
End Sub
Sub TabstopFocusOnClick()
Dim I As Integer
'''PARA USAR EVENTOS DE TECLAS PRESIONADAS EN EL TECLADO
On Error Resume Next
For I = 0 To Controls.Count - 1 ' Use the Controls collection
Controls(I).TabStop = False
Controls(I).TakeFocusOnClick = False
Next
End Sub
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
'AL PRESIONAR "N"
If KeyCode = 78 Then
Btn_NextStudent_Click
End If
End Sub