Moving Picture Box Using Arrow Keys
A program that enables to move the image to forward, backward , upward and downward inside the form using the arrow keys.
So, first step is to create a form and add a picture object, then upload any picture by navigating in the Image property of the picture object. Name the object picMove in Name properties.
Here’s mine.
So, first step is to create a form and add a picture object, then upload any picture by navigating in the Image property of the picture object. Name the object picMove in Name properties.
Here’s mine.
Copy and Paste then
code
Public Class frmMov'VARIABLE DECLARATIONDim NewPoint As PointPrivate Sub frmMov_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDownSelect Case e.KeyCodeCase Keys.UpNewPoint.Y = picMov.Location.Y - 5NewPoint.X = picMov.Location.XCase Keys.LeftNewPoint.Y = picMov.Location.YNewPoint.X = picMov.Location.X - 5Case Keys.DownNewPoint.Y = picMov.Location.Y + 5NewPoint.X = picMov.Location.XCase Keys.RightNewPoint.Y = picMov.Location.YNewPoint.X = picMov.Location.X + 5End SelectpicMov.Location = NewPointEnd SubEnd Class
Final Output
Moving Picture Box Using Arrow Keys
Reviewed by code-dev
on
4:30 PM
Rating:
No comments: