How To Move Object Around The Form In Visual Basic.Net
In This VB.Net Tutorial We Will See How To Move Panel UP, RIGHT, DOWN, LEFT In The Form By Pressing Arrow Keys Using Visual Basic.Net Programming Language And Visual Studio Editor.
Project Source Code:
Public Class Moving_Element
Private Sub Moving_Element_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
' move up
Case Keys.Up
Panel1.Location = New Point(Panel1.Location.X, Panel1.Location.Y - 1)
' move down
Case Keys.Down
Panel1.Location = New Point(Panel1.Location.X, Panel1.Location.Y + 1)
' move right
Case Keys.Right
Panel1.Location = New Point(Panel1.Location.X + 1, Panel1.Location.Y)
' move left
Case Keys.Left
Panel1.Location = New Point(Panel1.Location.X - 1, Panel1.Location.Y)
End Select
End Sub
End Class
///////////////OUTPUT:
Download Projects Source Code