窗体上放一个Label,三个Command按钮:
Dim h As Integer, m As Integer, s As Integer, ms As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1_Timer
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
h = 0
m = 0
s = 0
ms = 0
Label1.Caption = Format(h, "00") & ":" & Format(m, "00") & _
":" & Format(s, "00") & ":" & Format(ms, "000")
End Sub
Private Sub Form_Load()
Command1.Caption = "开始"
Command2.Caption = "停止"
Command3.Caption = "重置"
Label1.Caption = ""
Timer1.Interval = 10
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
ms = ms + 10
If ms > 999 Then s = s + 1: ms = 0
If s > 59 Then m = m + 1: s = 0
If m > 59 Then h = h + 1: m = 0
Label1.Caption = Format(h, "00") & ":" & Format(m, "00") & _
":" & Format(s, "00") & ":" & Format(ms, "000")
End Sub