Help in Movement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codeman54
    New Member
    • Jan 2007
    • 18

    Help in Movement

    I have a picturebox that moves around using the arrow keys by using this code:
    Code:
    If e.KeyValue = Keys.Right Then
             piccar.Left = piccar.Location.X + 6
          ElseIf e.KeyValue = Keys.Left Then
             piccar.Left = piccar.Location.X - 6
          End If
    how do i code it to make it move up and down? this has it going left and right across the form how do i make it move across the y axis (up and down)
  • balid
    New Member
    • Feb 2007
    • 18

    #2
    Originally posted by codeman54
    I have a picturebox that moves around using the arrow keys by using this code:
    Code:
    If e.KeyValue = Keys.Right Then
             piccar.Left = piccar.Location.X + 6
          ElseIf e.KeyValue = Keys.Left Then
             piccar.Left = piccar.Location.X - 6
          End If
    how do i code it to make it move up and down? this has it going left and right across the form how do i make it move across the y axis (up and down)
    Try something like this:
    Code:
    If e.KeyValue = Keys.Up Then
             piccar.Top = piccar.Location.Y - 6
          ElseIf e.KeyValue = Keys.Down Then
             piccar.Top = piccar.Location.Y + 6
          End If
    If your previous worked for left to right using Location.X then using Location.Y should work for up and down.

    Comment

    Working...