by Brandon (46 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 6th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Move a shape in any direction using up, down, left, and right arrow keys
'use all default names
Private Sub Text1_KeyDown(Keycode As Integer, Shift As Integer)
If Keycode = vbKeyUp Then
Position = "Up"
ElseIf Keycode = vbKeyDown Then
Position = "Down"
ElseIf Keycode = vbKeyLeft Then
Position = "Left"
ElseIf Keycode = vbKeyRight Then
Position = "Right"
End If
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 50
If Position = "Right" Then
Shape1.Left = Shape1.Left + 20
ElseIf Position = "Left" Then
Shape1.Left = Shape1.Left - 20
ElseIf Position = "Up" Then
Shape1.Top = Shape1.Top - 20
ElseIf Position = "Down" Then
Shape1.Top = Shape1.Top + 20
End If
Timer1.Enabled = False
End Sub
No comments have been posted about Move a shape in any direction using up, down, left, and right arrow keys. Why not be the first to post a comment about Move a shape in any direction using up, down, left, and right arrow keys.