Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27036

VS 2010 Escape key to close out Form/Window

$
0
0
Hi all & thanks for looking.

I was able to pickup keyboard button presses in VB5/6 years ago & I am trying to do this new (years later) in VB 10 Express.
It is so frustrating, but I cannot seem to get it to work, while it was so easy to do back then.

All I am trying to do is listen for the keyboard "ESC" key & close out the application (form/window) when it has been pressed.

The code can't get simpler than this:

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

If e.KeyCode = Keys.Escape Then
Me.Close()
End If

End Sub

Viewing all articles
Browse latest Browse all 27036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>