Discussion:
text boxes
(too old to reply)
Steve
2003-09-17 21:16:15 UTC
Permalink
Hi all i am writing a small program and what i need to do is have some code
that will do the following:

When i press a key within a text box it will type that letter/number in
and then move to the next text box in the tab order.

any help appreciated

steve
WhiteRavenEye
2003-09-17 21:54:53 UTC
Permalink
Post by Steve
Hi all i am writing a small program and what i need to do is have some code
When i press a key within a text box it will type that letter/number in
and then move to the next text box in the tab order.
any help appreciated
steve
Use KeyPress evet on textbox...

By WhiteRavenEye
Jeff Bennett
2003-09-18 14:33:43 UTC
Permalink
As per WhiteRavenEye,
trap the KeyPress event.
What he didn't say is that in this event you should call the SetFocus
method of the next textbox you want to move to.

The easiest way is to have all the textboxes in a nice array.
This way you can use the index parameter to keep track of which
textbox you are in and want to move to

For example

Sub TextBox_KeyPress(Index As Integer, KeyAscii As Integer)
' Assume you have textboxes from TextBox(0) to TextBox(30)
If Index < 30 Then
' set focus to next textbox
TextBox(Index + 1).SetFocus
Else
' set focus back to first textbox
' - or take other action if desired
TextBox(0).SetFocus
End If
End Sub


I hope this is helpful to you.


-----

* * Please include a copy of this note with your reply

Jeff Bennett President
***@Bennet-Tec.Com

Bennet-Tec Information Systems, Inc
50 Jericho Tpk, Jericho, NY 11753
Phone 516 997 5596, Fax - 5597
WWW.Bennet-Tec.Com

RELIABLE Component Software
and Software Development Services
* TList/Pro * ALLText HT/Pro * MetaDraw *

====================== ======================
Post by Steve
Hi all i am writing a small program and
what i need to do is have some code
When i press a key within a text box it
will type that letter/number in
and then move to the next text box in the tab order.
Use KeyPress evet on textbox...
By WhiteRavenEye
Rick Rothstein
2003-09-18 15:42:45 UTC
Permalink
Post by Jeff Bennett
What he didn't say is that in this event you should call the SetFocus
method of the next textbox you want to move to.
The easiest way is to have all the textboxes in a nice array.
This way you can use the index parameter to keep track of which
textbox you are in and want to move to
For example
Sub TextBox_KeyPress(Index As Integer, KeyAscii As Integer)
' Assume you have textboxes from TextBox(0) to TextBox(30)
If you make this change to the If statement, then you won't have to know the
number of TextBox'es in advance.

Sub TextBox_KeyPress(Index As Integer, KeyAscii As Integer)
If Index < TextBox.UBound Then
' set focus to next textbox
TextBox(Index + 1).SetFocus
Else
' set focus back to first textbox
' - or take other action if desired
TextBox(0).SetFocus
End If
End Sub

Rick - MVP

Loading...