Public x 1 'This is whats wrong - it says "End of statement expected" when mouse over
Public y 1 'the "1"
Private Sub Form_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
' if keypressed is right move the shape three more
' spaces to the right
If KeyCode = 68 Then
x = x + 3
shape1.Move(x, y)
End If
' if keypressed is left move the shape three more
' spaces to the left
If KeyCode = 65 Then
x = x - 3
shape1.Move(x, y)
End If
If KeyCode = 83 Then
y = y + 3
shape1.Move(x, y)
End If
If KeyCode = 86 Then
y = y - 3
shape1.Move(x, y)
End If
End Sub
Note Im completely new to this so keep it simple please!
Thanks!
This will move the label around with the WASD keys or the Up,Left,Down, or Right arrow keys. From its current Position.
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.A, Keys.Left
shape1.Location += New Size(-3, 0)
Case Keys.D, Keys.Right
shape1.Location += New Size(3, 0)
Case Keys.W, Keys.Up
shape1.Location += New Size(0, -3)
Case Keys.S, Keys.Down
shape1.Location += New Size(0, 3)
End Select
End Sub