Using return instead of Tab in VB?? 
Author Message
 Using return instead of Tab in VB??

I have an application that has a data entry type screen, within this screen I
would like the person to be able to use either the normal TAB key and the
Return key to move from text box field to text box field.

When I attempt to catch the return keypress and change it to a TAB so that the
focus will move to the next text box I still get the error beep from windows
and the focus does not move to the next text box.

How do I either get my app to accept returns and treat them like a TAB keypress?



Fri, 24 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

[snip]

Quote:
> When I attempt to catch the return keypress and change it to a TAB so that the
> focus will move to the next text box I still get the error beep from windows
> and the focus does not move to the next text box.

> How do I either get my app to accept returns and treat them like a TAB keypress?

     Sub Text1_KeyPress (KeyAscii As Integer)
         If KeyAscii = 13 Then   '13 is Key_Return
            SendKeys "{tab}"
            KeyAscii = 0
         End If
     End Sub

--

for Internet News....



Fri, 24 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

infinite reservoirs of wisdom:

Quote:
>How do I either get my app to accept returns and treat them like a TAB keypress?

Sub _KeyPress (...)
   If KeyAscii = 13 Then
                KeyAscii = 0
                SendKeys "{TAB}"
        End If
End Sub

Jens
--
Everything I said are the opinions of someone else.
I just cut-and-pasted.

Jens Balchen jr.       http://www.sn.no/~balchen



Fri, 24 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

Quote:


>[snip]
>> When I attempt to catch the return keypress and change it to a TAB so that the
>> focus will move to the next text box I still get the error beep from windows
>> and the focus does not move to the next text box.

>> How do I either get my app to accept returns and treat them like a TAB keypress?

>     Sub Text1_KeyPress (KeyAscii As Integer)
>         If KeyAscii = 13 Then   '13 is Key_Return
>            SendKeys "{tab}"
>            KeyAscii = 0
>         End If
>     End Sub

 Try using controlname.SETFOCUS, it's a little neater the sendkeys.

----
Kevin Woodward



Sat, 25 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??
Thanks for the TAB key help, I have never used the sendkey function and never
would have thought of it.   Thanks again.


Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??
Thanks for the assist with the TAB key problem, I really appreciate it.


Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??
Thanks for the ideas on the TAB key to return problem,  I must have had a brain
cramp....I was so busy trying to turn the return into a TAB that I never
thought of just moving the focus to the next field.


Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

Quote:
(KCW) writes:
> Try using controlname.SETFOCUS, it's a little neater the sendkeys.

how pray tell, do we know where to set focus to?  you arent suggesting we
hard code the next controlname in the tab order in each proc are you?


Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

infinite reservoirs of wisdom:

Quote:
>>            SendKeys "{tab}"

> Try using controlname.SETFOCUS, it's a little neater the sendkeys.

Not really, since you rarely take the time to figure out what
control comes next in the tab order.

Jens
--
Everything I said are the opinions of someone else.
I just cut-and-pasted.

Jens Balchen jr.       http://www.sn.no/~balchen



Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??
In the KeyPress Event of the Text Box Type:

If KeyAscii=13 then
   KeyAscii=0
   SendKeys "{TAB}"
End if

or declare a subroutine to do it and call it from the same event.
The KeyAscii =0 turns the beep off



Sun, 26 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

Quote:

>infinite reservoirs of wisdom:

>>>            SendKeys "{tab}"

>> Try using controlname.SETFOCUS, it's a little neater the sendkeys.

>Not really, since you rarely take the time to figure out what
>control comes next in the tab order.

I was thinking that the text boxes would be in an array,
eg.

Sub Text1_KeyDown (Index As Integer, KeyCode As Integer, Shift As
Integer)
If keycode = 13 then    
        If index = no. of text boxes then exit sub
        Text1(index+1).setfocus
endif
End Sub

...and by sending tab don't you have to set up the tab order.

Any way, every man to his own.

Regards,
KCW.



Tue, 28 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

Quote:

>I was thinking that the text boxes would be in an array,
>eg.

>Sub Text1_KeyDown (Index As Integer, KeyCode As Integer, Shift As
>Integer)
>If keycode = 13 then    
>        If index = no. of text boxes then exit sub
>        Text1(index+1).setfocus
>endif
>End Sub

If the focus is on the form and not the text box then this won't work because
the text box will never receive the focus. Plus this won't work if you are
using other type of controls like combo boxes, options ,etc.


Fri, 31 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

Quote:

>I have an application that has a data entry type screen, within this screen I
>would like the person to be able to use either the normal TAB key and the
>Return key to move from text box field to text box field.

>When I attempt to catch the return keypress and change it to a TAB so that the
>focus will move to the next text box I still get the error beep from windows
>and the focus does not move to the next text box.

>How do I either get my app to accept returns and treat them like a TAB

keypress?

Global Const KEY_RETURN = &HD
Form_KeyDown (KeyCode as Integer, Shift as Integer)
    If KeyCode = KEY_RETURN THEN
            Form1.SetFocus
            SendKeys "{Tab}"
    End if
End Sub

You need the set focus on the form to make sure it works right all the time.



Fri, 31 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??

says...

Quote:
>>     Sub Text1_KeyPress (KeyAscii As Integer)
>>         If KeyAscii = 13 Then   '13 is Key_Return
>>            SendKeys "{tab}"
>>            KeyAscii = 0
>>         End If
>>     End Sub

> Try using controlname.SETFOCUS, it's a little neater the sendkeys.

Unless you want to walk the tabindex you can't tell which control is next. It
is cleaner to set the order on the data entry form by the tabindex and use
sendkeys {tab} and sendkeys +{tab} to walk the entry form by keys other than
tab.


Fri, 31 Jul 1998 03:00:00 GMT  
 Using return instead of Tab in VB??
Re: Using return instead of Tab in VB??

Hi there!
Try this: Text1 and Text2-when user is in Text1 and ENTER is pressed
cursor should move to Text2.
It goes like that:

Sub Text1_KeyPress (keyascii As Integer)
If keyascii = 13 Then
text2.SetFocus
End If
End Sub

That's all, folks!

Joachim Hornig


http://ourworld.compuserve.com/homepages/SOUNDVISION/homepage.htm



Mon, 10 Aug 1998 03:00:00 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. problem using component with asp page -- result of function not returned, instead original value returned

2. return instead of tab

3. return instead of tab

4. Using the enter key instead of tab?

5. Using ENTER instead of TAB to progress to next TextBox

6. Help using Enter key instead of Tab in Visual Basic for Dos

7. Help: Scrolling data controls using Enter key instead of Tab

8. Help using <CR> instead of TAB

9. Help: Scrolling data controls using Enter key instead of Tab

10. Using SQL2000, returning an XML document (string) instead of a recordset, from a stored procedure

11. Using Return-key as if it were the Tab-key in VB5

12. Using Return-key as if it were the Tab-key in VB5

 

 
Powered by phpBB® Forum Software