Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keypress event and tab-button 2

Status
Not open for further replies.

stx

Programmer
Sep 24, 2002
62
0
0
BE
Hi

Is it possible the keypress event of a textbox isn't fired when you press the tab-button on the keyboard?
How can i make sure it does?

thnx
 
Hi,

Use Keydown event instead of Keypress event if you want to use function keys. I think this will do your work

Best of luck
 
Try this:

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 8 Then
KeyCode = 0
End If
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Guys

the keydown event you suggested only works when there is no other textbox (or other control that can get the focus) on the form.

when you draw a form with 2 textboxes and you press the tab-button on the first textbox,his keydown event will not be fired, instead the focus will be given at the second textbox.

I need to be able to catch the tab-button pressed on the first text-box.

Any thoughts are welcome
thnx
 
I'm not sure what you want to do with the Tab key.

If you don't want to Tab from control to control, set the TabStop property to False for any property you don't want to Tab to.

If something else, please clarify
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
ok i'll clarify

if the enter-button or the tab-button is pressed on a textbox, i want to do some checks about the data that was inputted in the textbox.

if the data is correct, i want to give the focus to one control,if the data isn't correct another control gets the focus.
That is briefly what i want to do.

The lostfocus event is not an option because when i click any other control on my form (for example a dropdownlist) the lostfocus event got fired and my tests would give the focus to another object than the one clicked.

i hope this makes my situation a little more understandable.
 
Look at the Validate event - it's designed for this situation
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top