VB中怎么控制小球的左右移动和停止,要代码!!!
推荐于2016-01-14
展开全部
Dim fh As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
fh = 1
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Timer1.Interval = 100
Timer1.Enabled = False
Command1.Caption = "开始"
Command2.Caption = "停止"
End Sub
Private Sub Timer1_Timer()
Shape1.Left = Shape1.Left + fh * 200
If Shape1.Left < 0 Then
Shape1.Left = 0
fh = -fh
End If
If Shape1.Left + Shape1.Width > Me.Width Then
Shape1.Left = Me.Width - Shape1.Width
fh = -fh
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询