JayneBR
asked on
Move a control using the up and down arrows.
I want to build a PONG game and use the up and down arrows to move the paddles (picturebox with white backcolor sahped like pong paddle with no picture). I have tried the following code with no success. It doesn't seem like an event is being triggered by the Form_Keydown event. What am I missing?
Private Sub Form_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
Form1.ActiveForm.KeyPrevie w = True
Select Case KeyCode
Case 38
pic1.Top -= 10
Case 40
pic1.Top += 10
End Select
End Sub
Private Sub Form_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
Form1.ActiveForm.KeyPrevie
Select Case KeyCode
Case 38
pic1.Top -= 10
Case 40
pic1.Top += 10
End Select
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEv
Form1.ActiveForm.KeyPrevie
Select Case e.KeyCode
Case 38
pic1.Top -= 10
Case 40
pic1.Top += 10
End Select
End Sub