By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,619 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,619 IT Pros & Developers. It's quick & easy.

Help in Movement

P: 18
I have a picturebox that moves around using the arrow keys by using this code:
Expand|Select|Wrap|Line Numbers
  1. If e.KeyValue = Keys.Right Then
  2.          piccar.Left = piccar.Location.X + 6
  3.       ElseIf e.KeyValue = Keys.Left Then
  4.          piccar.Left = piccar.Location.X - 6
  5.       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)
Mar 20 '07 #1
Share this Question
Share on Google+
1 Reply


balid
P: 18
I have a picturebox that moves around using the arrow keys by using this code:
Expand|Select|Wrap|Line Numbers
  1. If e.KeyValue = Keys.Right Then
  2.          piccar.Left = piccar.Location.X + 6
  3.       ElseIf e.KeyValue = Keys.Left Then
  4.          piccar.Left = piccar.Location.X - 6
  5.       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:
Expand|Select|Wrap|Line Numbers
  1. If e.KeyValue = Keys.Up Then
  2.          piccar.Top = piccar.Location.Y - 6
  3.       ElseIf e.KeyValue = Keys.Down Then
  4.          piccar.Top = piccar.Location.Y + 6
  5.       End If
  6.  
If your previous worked for left to right using Location.X then using Location.Y should work for up and down.
Mar 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.