Treat Enter key as Tab key

Smee

Well-Known Member
Licensed User
Longtime User
i'm on fire with questions tonight!

How can the enter key be accepted to perform the same way as the tab key?

when a number is entered into a text box the software ignores the enter key but will accept the TAB key

Thanks all

Joe
 
Last edited:

klaus

Expert
Licensed User
Longtime User
What is, for you, the Enter key supposed to do.

If you have a monoline TextBox the Enter key has no meaning.
When you set your TextBox multiline the Enter key works fine.

If the Enter key is supposed to do something else, you can trap it with the TextBox KeyPress event and text if Asc(key) = 13.

Best regards.
 

Smee

Well-Known Member
Licensed User
Longtime User
Many Thanks Klaus,

I will play around and see what i can do. I am using a scanner and i think it puts asc(13) on the end of the first input string
 

ceaser

Active Member
Licensed User
Hi Smee

Normally your "Tab" key will send the focus to some other part of the program. If I understand you correctly, then you want to press "Enter" on your PDA and the focus must be send somewhere else, or even some other action must happen in your program.

How about:

Sub Textbox2_Keypress(Keypress)
If Keypress=Chr(13) Then
Textbox2.IgnoreKey
Textbox3.Focus
...................do something else
End If
End Sub

Regards
Michael (alias Ceaser:))
 

Smee

Well-Known Member
Licensed User
Longtime User
Thanks Michael and Klaus,

I have tried the code snippets and whilst they work on the desktop they do not work with the scanner unit.

What happens is this;

on the desktop i type the barcode into textbox1 then press the tab key which sends the focus to textbox2, all good. then i enter another number into text box 2 and press the enter key. Voila the code works and focus returns to textbox1.

However on the unit i SCAN the barcode into textbox1 and the focus automatically moves to textbox2. Without the code snippet of
'Textbox2_Keypress(Keypress)' the focus remains in textbox2 and i press a number and TAB key it moves focus to textbox1 correctly. if i press return key nothing happens.

Now when i use the Keypress code snippet the focus goes from textbox1 to textbox2 and straight back to textbox1 again WITHOUT pressing either return or tab key. I know the focus is bouncing across because i preload textbox2 with a number

Thanks

Joe
 

Ariel_Z

Active Member
Licensed User
Interesting! maybe the scanner adds some characters? Maybe duplicate tab? Could you try adding a messagebox to the TextBox2_KeyPress and see which key is pressed? I would also add messages to the GotFocus and LostFocus, just for the interest to see the order, and see what happens.
 

Smee

Well-Known Member
Licensed User
Longtime User
thanks guys that did it.

The scanwedge was configured to send BOTH the tab key and return key after the scan so once i had turned on the keypress event the return key was activating from the scanner as well.

All working as expected now

Now for my next question in this learning curve
 
Top