相遇问题动画演示-精2

分类: VB |
相遇问题动画演示-精2
Option Explicit
Dim i As Long
Dim v As Long
'思路:1小时50公里,则3600秒50000米,则每36秒500米
'故设时钟周期为36,两车速度分别为500米、800米
'一个时钟同时控制两辆小车
PrivateSub Form_Load() '初始化
Me.ScaleMode = 3 'pixel
Picture1.Scale (0, 0 ) - (100000, 400 )
EndSub
PrivateSub Command1_Click() '出发
i = 0
carA. Left = 0
carB. Left = 100000
Timer1.Interval = 36
EndSub
PrivateSub Command2_Click() '暂停
If Command2.Caption = "暂停" Then
Timer1.Interval = 0
Command2.Caption = "继续"
Exit Sub
End If
If Command2.Caption = "继续" Then
Timer1.Interval = 36
Command2.Caption = "暂停"
End If
EndSub
PrivateSub Command3_Click() '复位
carA.Left = 0
carB. Left = 100000
Command2.Caption = "暂停"
EndSub
PrivateSub Timer1_Timer() '周期事件
Label2.Caption = i * 500 / 1000 & " 公里 "
Label3.Caption = i * 36 / 60 & " 分钟 "
i = i + 1
If carA.Left < carB.Left - 500 Then
carA.Left = carA.Left + 500
carB. Left = carB.Left - 800
Else
Timer1.Interval = 0
End If
EndSub
Dim
Dim
'思路:1小时50公里,则3600秒50000米,则每36秒500米
'故设时钟周期为36,两车速度分别为500米、800米
'一个时钟同时控制两辆小车
Private
End
Private
End
Private
End
Private
End
Private
End
前一篇:VB6输入代码时自动整理功能修复
后一篇:VB:关于弹簧振子的动画