- Home
·
- Graphics
·
- Move a shape in any direction using up, down, left, and right arrow keys
Move a shape in any direction using up, down, left, and right arrow keys
Move a shape in any direction using up, down, left, and right arrow keys
Rate Move a shape in any direction using up, down, left, and right arrow keys
(1(1 Vote))
'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
Move a shape in any direction using up, down, left, and right arrow keys Comments
No comments yet — be the first to post one!
Post a Comment