VB6.0计时器

来源:百度知道 编辑:UC知道 时间:2024/06/08 11:27:27
我用VB6.0做了一个计时器,但是格式是0:0:0的,如果要变成00:00:00的格式,因该怎么修改.
Dim mm, ss, us As Integer

Private Sub Form_Load()
Command1.Caption = "开始"
Command2.Caption = "停止"
Timer1.Enabled = False
Timer1.Interval = 10
End Sub

Private Sub Command1_Click()
mm = 0
ss = 0
us = 0
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
If us < 100 Then
us = us + 1
Else
us = 0
If ss < 60 Then
ss = ss + 1
Else
ss = 0
mm = mm + 1
End If
End If
Label1.Caption = mm & ":" & ss & ":" & us
End Sub

Dim mm, ss, us As Integer

Private Sub Form_Load()
Command1.Caption = "开始"
Command2.Caption = "停止"
Timer1.Enabled = False
Timer1.Interval = 10
End Sub

Private Sub Command1_Click()
mm = 0
ss = 0
us = 0
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
If us < 100 Then
us = us + 1
Else
us = 0
If ss < 60 Then
ss = ss + 1
Else
ss = 0
mm = mm + 1
End If
End If
if mm<10 then
if ss<10 then
if us <10 then
label1.caption="0" & mm & ":0" &ss & ":0" &us
else
label1.caption="0" & mm & ":0" &ss & ":" &us
end if
else
if us <10 then
label1.caption="0" & mm & ":" &ss