In addition to the others, here is a more elegent snipit.
'A textbox example.
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Select Case e.KeyCode
Case Keys.Down ' << Note this useful enumeration
MsgBox("DOWN")
Case Keys.Up
MsgBox("UP")
Case Keys.Left
MsgBox("LEFT")
Case Keys.Right
MsgBox("RIGHT")
End Select
In addition to the others, here is a more elegent snipit.
'A textbox example.
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Select Case e.KeyCode
Case Keys.Down ' << Note this useful enumeration
MsgBox("DOWN")
Case Keys.Up
MsgBox("UP")
Case Keys.Left
MsgBox("LEFT")
Case Keys.Right
MsgBox("RIGHT")
End Select
This will not work, if there are, for example, buttons on the form --
even if 'KeyPreview' is set to 'True'.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.