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!

Recommended Answers

All 3 Replies

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

But Picturebox cant move when button in the form...
How can i Rapair it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.