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毫秒!
博客展示了使用Timer控件实现秒表功能的代码,包含timeGetTime函数获取时间,设置Timer1的相关属性,以及自定义mytime函数格式化时间。同时提醒,TIMER控件实现的秒表精度只有55毫秒。

2068

被折叠的 条评论
为什么被折叠?



