倒记时器 如何做

来源:百度知道 编辑:UC知道 时间:2024/05/10 18:02:54
请教一个vb 的60秒倒记时器 的代码
是 倒计时器 不是计时器

Private Declare Function GetTickCount& Lib "kernel32" ()
Dim starttm!, elaptm!, accutm!
Private Sub Form_Load()
Timer1.Interval = 1
Command1.Caption = "开始"
Command2.Caption = "fuwei"
Me.Caption = "jishiqi"
Command2_Click
End Sub

Private Sub Command1_Click()
If Command1.Caption = "开始" Then
starttm = GetTickCount
Timer1.Enabled = True
Command1.Caption = "停"
Else
accutm = accutm + elaptm
Timer1.Enabled = False
Command1.Caption = "开始"
End If
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
accutm = 0: elaptm = 0
Command1.Caption = "开始"
Me.Caption = "jishiqi"
End Sub

Private Sub Timer1_Timer()
elaptm = GetTickCount - starttm
Me.Caption = Format(CStr((accutm + elaptm) / 1000), "0.000") & " 秒"
End Sub