Link to home
Start Free TrialLog in
Avatar of keithedwardb
keithedwardbFlag for United Kingdom of Great Britain and Northern Ireland

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
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use the Key_Up eventof the text box to handleONLY the keys you want
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keithedwardb

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.