LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default keydown, arrow keys problem

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem moving frm cell2cell with keyboard arrow keys Pam Excel Discussion (Misc queries) 1 March 14th 10 05:40 PM
scroll with arrow keys problem Accounts Diva Excel Worksheet Functions 1 September 4th 08 03:37 AM
Arrow Keys Tim Excel Discussion (Misc queries) 1 January 24th 08 06:10 PM
Keydown and SelStart problem jase[_2_] Excel Programming 2 December 6th 05 01:46 PM
arrow keys Dean Excel Discussion (Misc queries) 1 February 14th 05 02:29 PM


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"