PC Review


Reply
Thread Tools Rate Thread

Changing Character Entered

 
 
Ricky W. Hunt
Guest
Posts: n/a
 
      7th Jul 2004
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


 
Reply With Quote
 
 
 
 
One Handed Man \( OHM - Terry Burns \)
Guest
Posts: n/a
 
      7th Jul 2004
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" <(E-Mail Removed)> wrote in message
newsVNGc.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
>
>



 
Reply With Quote
 
Ricky W. Hunt
Guest
Posts: n/a
 
      7th Jul 2004
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eov9ui$(E-Mail Removed)...
> 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?


 
Reply With Quote
 
One Handed Man \( OHM - Terry Burns \)
Guest
Posts: n/a
 
      7th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:BvWGc.41611$Oq2.16065@attbi_s52...
> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
> news:eov9ui$(E-Mail Removed)...
> > 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?
>
>



 
Reply With Quote
 
Ricky W. Hunt
Guest
Posts: n/a
 
      8th Jul 2004
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation of the First Character entered in a cell. =?Utf-8?B?amF1c3Rpbg==?= Microsoft Excel Programming 4 10th Aug 2007 04:28 PM
requery as each character entered =?Utf-8?B?SWFu?= Microsoft Access Forms 5 5th Feb 2007 08:32 PM
preventing special character from being entered in cell =?Utf-8?B?a3VuYWwgU2hhcm1h?= Microsoft Excel Programming 1 15th Sep 2006 04:17 PM
the expression entered exceeds the 1,024-character limit for the q =?Utf-8?B?UGF0cmljayBCcmlnZ3M=?= Microsoft Access Queries 6 10th Aug 2006 02:30 AM
windows 2K character displayed does not match key entered mike Microsoft Windows 2000 1 1st Dec 2003 08:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 PM.