We help IT Professionals succeed at work.
Get Started

Handling Esc key in Vb.net

4,636 Views
Last Modified: 2007-12-19
HI,

I want to trap the esc key.  As soon as the user presses the esc key the form should close.

In the forms cancelbutton property i have associated this with cmdClose button.  In the cmdClose_click() event I have written me.close.So as soon as the escape is pressed the form will close.

The problem is I have a textbox and in its leave event I have written a validate function to check the details entered in the textbox.  

If the user enters something in the textbox and click the esc key, the validate function fires unnecessarily.    I don't want this.

As soon as the user press the esc key when the focus  is in the text box, I don't want to fire the validate function.  I just want to close the form.

Please help me out in doing this.

Thanks.


Comment
Watch Question
Top Expert 2004
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE