
我想制作一个VB程序,运行后,按住"左箭头",picture1就向左移动,按住"右箭头"就向右移动...???
展开全部
窗体上放一个Picture1,两个按钮,一个时钟Timer1控件
Enum DirectionConst
toLeft = 1
toRight = 2
noMove = 0
End Enum
Dim Direction As DirectionConst
Const StepCount = 100
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
Direction = toLeft
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Direction = noMove
End Sub
Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
Direction = toRight
End Sub
Private Sub Command2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Direction = noMove
End Sub
Private Sub Form_Load()
Timer1.Interval = 60
End Sub
Private Sub Timer1_Timer()
Select Case Direction
Case noMove
Timer1.Enabled = False
Case toRight
Picture1.Left = Picture1.Left + StepCount
Case toLeft
Picture1.Left = Picture1.Left - StepCount
End Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询