473,505 Members | 14,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing Character Entered

Is there is a way to "change" what character the user typed? For instance,
is there anything I can put in a Keypress handler that if the user pressed
the <Enter> key it make it appear to the program that <Tab> was pressed? I'm
going through some tutorials that has a number validation routine (to ensure
only numbers were pressed, etc.) and it has a check to see if the <Enter>
key was pressed, and if so to set the focus to the next text box. Since
there's a bunch of these text boxes this code has to be copied into then
Keypress handler for each one. A subroutine won't work because the box you
want to transfer focus on depends on which box you are currently in. I
thought if I could make it appear to the program as though the user had
pressed Tab when they pressed Enter the cursor would jump to the correct box
(as set up by Tab order) and therefore I'd have a "universal" subroutine
that could be used for all the boxes.

--
Thanks,
Ricky W. Hunt
freendeed
Nov 20 '05 #1
4 1219
Well firstly, there are two ways to handle this situation. You could create
a handler for the first text box and then add more handles statements for
all the others you want this sub to handle ( 1 sub, handles all your txt
boxes. ), or you can set the form to Preview in the properties, and check
the keypress event for the form, this way you will trap all kepress events
and the form previews them before passing them on the handler for the
control that called them.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Ricky W. Hunt" <rh*****@hotmail.com> wrote in message
news:DVNGc.22299$JR4.2660@attbi_s54...
Is there is a way to "change" what character the user typed? For instance,
is there anything I can put in a Keypress handler that if the user pressed
the <Enter> key it make it appear to the program that <Tab> was pressed? I'm going through some tutorials that has a number validation routine (to ensure only numbers were pressed, etc.) and it has a check to see if the <Enter>
key was pressed, and if so to set the focus to the next text box. Since
there's a bunch of these text boxes this code has to be copied into then
Keypress handler for each one. A subroutine won't work because the box you
want to transfer focus on depends on which box you are currently in. I
thought if I could make it appear to the program as though the user had
pressed Tab when they pressed Enter the cursor would jump to the correct box (as set up by Tab order) and therefore I'd have a "universal" subroutine
that could be used for all the boxes.

--
Thanks,
Ricky W. Hunt
freendeed

Nov 20 '05 #2
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
Well firstly, there are two ways to handle this situation. You could create a handler for the first text box and then add more handles statements for
all the others you want this sub to handle ( 1 sub, handles all your txt
boxes. ), or you can set the form to Preview in the properties, and check
the keypress event for the form, this way you will trap all kepress events
and the form previews them before passing them on the handler for the
control that called them.


Yes but how does the one sub know where to put the focus next? It doesn't
seem like I should have to write a Case statement with the sub for each box
just to set focus. Why isn't here some "generic" command that just says "set
focus to the next control according to tab order" or something to that
effect?
Nov 20 '05 #3
Easy . . . In each handler or in the form's keypress with KepPreview to on

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If e.KeyChar = ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
End If
End Sub
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Ricky W. Hunt" <rh*****@hotmail.com> wrote in message
news:BvWGc.41611$Oq2.16065@attbi_s52...
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:eo**************@TK2MSFTNGP11.phx.gbl...
Well firstly, there are two ways to handle this situation. You could create
a handler for the first text box and then add more handles statements for all the others you want this sub to handle ( 1 sub, handles all your txt
boxes. ), or you can set the form to Preview in the properties, and check the keypress event for the form, this way you will trap all kepress events and the form previews them before passing them on the handler for the
control that called them.


Yes but how does the one sub know where to put the focus next? It doesn't
seem like I should have to write a Case statement with the sub for each

box just to set focus. Why isn't here some "generic" command that just says "set focus to the next control according to tab order" or something to that
effect?

Nov 20 '05 #4
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Easy . . . In each handler or in the form's keypress with KepPreview to on

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If e.KeyChar = ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
End If
End Sub


Thanks. That's what I was asking for (but didn't know how to phrase it). In
other words, "how do I load the keyboard buffer to make it look like the
user hit such-and-such key". I will look into SendKeys. Thanks again.
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1958
by: Gary | last post by:
Morning all, I have a form field called: Bsk01 How do I onBlur prompt the user to enter a ZERO as character one, if one is not already entered. At the same time, I would like to ensure at...
2
1979
by: Pmb | last post by:
How are character strings input from the user. For example: Suppose I have the code ____________________________________ #include <iostream.h> int main() { char nameString; cout << "Enter...
37
10115
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
6
6196
by: Gus Tabares | last post by:
Hello, I'm having trouble reading in a character. Here is a snippet of code: int num; char character; printf("Enter a number: "); scanf("%d", &num); printf("You entered %d.\n", num);
7
96256
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
5
1921
by: Kay | last post by:
Hi All, I'm trying to write a small sub/function to replace some (invalid) character in a combo box, or may be even text box. For example, I have several combo boxes that allows user to select...
1
2249
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a KeyDown event in which I would like to determine if the current key is a standard character (i.e., from the ASCII character set). In C I would use something like the isascii...
35
4204
by: rajash | last post by:
Hello everyone, Thanks again for all the suggestions, though I think some people are a bit fussy in their answers. Here is a solution to Exercise 1.14. It deals well with control characters...
7
2536
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.