模拟匀减速运动:Dim BuChang As Double, v As Double '''步长 和 速度 Const a = -0.1Private Sub Form_Load() Me.Move 0, 0, Screen.Width, Screen.Height Shape1.Move -Shape1.Width, Me.Height / 2 - Shape1.Height, 2000, 2000 Shape1.BackColor = &HFF0000 Shape1.BorderWidth = 5
Timer1.Enabled = True Timer1.Interval = 100
BuChang = (Me.Width + Shape1.Width) / 2 / 10 v = BuChang End SubPrivate Sub Timer1_Timer() If Shape1.Left > (Me.Width - Shape1.Width) / 2 Then Timer1.Enabled = False Exit Sub Else v = v + v * a Shape1.Left = Shape1.Left + v End If End Sub
Const a = -0.1Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
Shape1.Move -Shape1.Width, Me.Height / 2 - Shape1.Height, 2000, 2000
Shape1.BackColor = &HFF0000
Shape1.BorderWidth = 5
Timer1.Enabled = True
Timer1.Interval = 100
BuChang = (Me.Width + Shape1.Width) / 2 / 10
v = BuChang
End SubPrivate Sub Timer1_Timer()
If Shape1.Left > (Me.Width - Shape1.Width) / 2 Then
Timer1.Enabled = False
Exit Sub
Else
v = v + v * a
Shape1.Left = Shape1.Left + v
End If
End Sub