I'm sure there is a simple way to make a keystrok such as the up arrow adjust the location of the picture box, however I don't know how to tell the program to perhaps

picturebox1.location = picturebox1.location + 1

when a key is pressed...

help please!

9 Years
Discussion Span
Last Post by sinici.grand

Actually scratch that, I really just want to know how I would say....

make a text box say "Left Key Pressed!" when i push the left key?


handle it with keyDown Event.
this following code is form keydown event, you can do same with other controls.

Private Sub Search_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Up Then
            'PictureBox1.Top -= 10
            MsgBox("Key Up Pressed")
        ElseIf e.KeyCode = Keys.Down Then
            'PictureBox1.Top += 10
            MsgBox("Key Top Pressed")
        ElseIf e.KeyCode = Keys.Left Then
            'PictureBox1.Left -= 10
            MsgBox("Key Left Pressed")
        ElseIf e.KeyCode = Keys.Right Then
            'PictureBox1.Left += 10
            MsgBox("Key Right Pressed")
        End If
    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.