Click to See Complete Forum and Search --> : Detect TAB key


February 24th, 2000, 09:30 AM
I have problem detecting the TAB key. The Help said
Keypress event can detect Enter, Tab, and Backspace
keys. I tried with a form and two text boxes. I couldn't
trap the TAB key in KeyPress or KeyUp, KeyDown events
when I press the TAB. I then tried setting KeyPreview = True
for the form. But still it didn't work.
My key board is configured with United States 101.
I'm using VB6 on Windows 98 Version 1, Pentium II 200Mhz.
What do I miss here?

JimmyT
February 24th, 2000, 10:09 AM
As another alternative, if you are performing validation of the data in the text field when the tab key is pressed, the tab key will cause the text box control to Lose Focus. You could place your validation code into the TextBox_LostFocus event or into the Validate event as well. You don't seem to be able to trap the tab key press if there is another control that can gain focus. The order of event firing after the tab key is pressed is 'Validate' followed by 'LostFocus'.


Good Luck...