P
Pointrider
I'm trying to use the keydown event to make the down arrow key change
the selected item in a listbox. The focus is in a texbox, and I've put
my code into the textbox_keydown event. The listbox selection is
changed, but then the focus is moved from the textbox to the next
control on the form. I don't want this... I want it to stay in the
textbox. How can I do this?
My event code is:
Private Sub NameBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyDown Then
Application.EnableEvents = False
With NamesListBox
If .ListIndex < .ListCount - 1 Then
.ListIndex = .ListIndex + 1
End If
End With
Application.EnableEvents = True
Exit Sub
End If
End Sub
Thanks for any help.
the selected item in a listbox. The focus is in a texbox, and I've put
my code into the textbox_keydown event. The listbox selection is
changed, but then the focus is moved from the textbox to the next
control on the form. I don't want this... I want it to stay in the
textbox. How can I do this?
My event code is:
Private Sub NameBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyDown Then
Application.EnableEvents = False
With NamesListBox
If .ListIndex < .ListCount - 1 Then
.ListIndex = .ListIndex + 1
End If
End With
Application.EnableEvents = True
Exit Sub
End If
End Sub
Thanks for any help.