469,362 Members | 2,548 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

text boxes

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
Jul 17 '05 #1
3 7586
Steve wrote:
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


Use KeyPress evet on textbox...

By WhiteRavenEye

Jul 17 '05 #2
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
Je**@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 *

====================== ======================
Steve wrote:
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.
WhiteRavenEye wrote

Use KeyPress evet on textbox...

By WhiteRavenEye

Jul 17 '05 #3
> 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
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by BurntWithTime | last post: by
4 posts views Thread by Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post: by
6 posts views Thread by =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post: by
6 posts views Thread by noe1818 via AccessMonster.com | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.