加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

相遇问题动画演示-精2

(2022-05-03 08:26:40)
分类: VB
相遇问题动画演示-精2
相遇问题动画演示-精2

相遇问题动画演示-精2

Option Explicit
Dim 
As Long
Dim As Long
'思路:1小时50公里,则3600秒50000米,则每36秒500米
'故设时钟周期为36,两车速度分别为500米、800米
'一个时钟同时控制两辆小车

Private Sub Form_Load()    '初始化
    
Me.ScaleMode     'pixel
    
Picture1.Scale (0, 0) - (100000, 400)
End Sub

Private Sub 
Command1_Click()    '出发
    
0
    carA.Left 0
    carB.Left 100000
    Timer1.Interval 36
End Sub

Private Sub 
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
End Sub

Private Sub 
Command3_Click()    '复位
    
carA.Left 0
    carB.Left 100000
    Command2.Caption "暂停"
End Sub

Private Sub 
Timer1_Timer()      '周期事件
    
Label2.Caption 500 1000 " 公里"
    Label3.Caption 36 60 " 分钟"
    1
    If carA.Left carB.Left 500 Then
        
carA.Left carA.Left 500
        carB.Left carB.Left 800
    Else
        
Timer1.Interval 0
    End If
End Sub

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有