---
title: "关于秒表"
author: "cjc"
date: "2005-08-29T23:45:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2005-08-29T23:45:00Z"
id: 299162
url: "https://cjc.iteye.com/blog/299162"
---

Private Declare Function timeGetTime Lib "winmm.dll" () As Long  
Dim STARTTIME As Long

Private Sub Command1\_Click()  
STARTTIME = timeGetTime  
Timer1.Enabled = True  
End Sub

Private Sub Form\_Load()  
Label1.Caption = mytime(0)  
Timer1.Interval = 1  
Timer1.Enabled = False  
End Sub

Private Sub Timer1\_Timer()  
Label1.Caption = mytime(timeGetTime - STARTTIME)  
End Sub  
Function mytime(ByVal thetime As Long) As String  
mytime = Format(thetime Mod 1000, "000")  
thetime = thetime \\ 1000  
mytime = Format(TimeSerial(0, 0, thetime), "HH:MM:SS") & ":" & mytime  
End Function

需要注意的是,TIMER控件实现的秒表精度只有55毫秒!