keithedwardb
asked on
VB.Net - How do I prevent a text box changed event firing unless the user presses TAB (or ENTER)
Hi,
I want to be able to error check the value of a textbox (could be decimal, float, text or integer). At the moment as soon as the user begins to type (anything) into the text box, the change event fires and various msgboxes appear depending upon whether the text input was numeric or not.
Is ther a way of switching off the event until the user presses the Enter or TAB key to indicate they are ready to move on to the next field?
I suspect something like: if keydown = TAB or ENTER, then error check, otherwise ignore.
Any ideas, please?
Thanks.
Keith
I want to be able to error check the value of a textbox (could be decimal, float, text or integer). At the moment as soon as the user begins to type (anything) into the text box, the change event fires and various msgboxes appear depending upon whether the text input was numeric or not.
Is ther a way of switching off the event until the user presses the Enter or TAB key to indicate they are ready to move on to the next field?
I suspect something like: if keydown = TAB or ENTER, then error check, otherwise ignore.
Any ideas, please?
Thanks.
Keith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use the Key_Up eventof the text box to handleONLY the keys you want
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Guys,
Thanks for this. I used both the keypress and the validating to error trap and this now works. I daresay the code can be refined and streamlined in due course but it gets me out of a hole.
Thanks again.
Thanks for this. I used both the keypress and the validating to error trap and this now works. I daresay the code can be refined and streamlined in due course but it gets me out of a hole.
Thanks again.