I'm using VB 2010 Express.
In C#
I would set the forms CancelButton
property.
For this VB form I don't have a CancelButton so I suspect I need to program either KeyPress
or KeyDown
.
- What is the difference between these two events?
- Which should I use?
I assume the general code for this is as follows?:
If e.KeyCode = Keys.Escape Then Close() End If
I have certain .Focus
code within other controls of the form then it becomes pointless putting this in the main forms event procedure as the main form never really has the focus.