Usually if you have a Cancel button on the form or similar you can simply set the CancelButton property of the form to that button, but in my case I didn't have that button on the form nor I want to add one.
I tried using the KeyDown event, but, strange, pressing ESC or every other key didn't fire the event routine.
As I didn't have time to investigate and find out why it happened I preferred to search in internet for some easy and fast solution, I find one post from Adam Butler that worked,
it was in C# so I had to simply translate in VB.NET
here's the code to put in your form code to be closed:
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As BooleanIf (keyData = Keys.Escape) ThenMe.Close()Return TrueEnd IfReturn MyBase.ProcessCmdKey(msg, keyData)End Function