Keyboard Input?

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
Hello
I have a PictureBox on the Form. I want it to move on the Form by using the arrow keys on the keyboard.

Pls let me know HOW.
 
Use this code:

VB.NET:
Private Sub Form1_KeyUp(ByVal sender As Object, _
  ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
    Select Case e.KeyCode
        Case Keys.Left
            PictureBox1.Left -= 1
        Case Keys.Right
            PictureBox1.Left += 1
        Case Keys.Up
            PictureBox1.Top -= 1
        Case Keys.Down
            PictureBox1.Top += 1
    End Select
End Sub
 
Back
Top