关于一个秒表的编程,怎么这样不行

来源:百度知道 编辑:UC知道 时间:2024/05/19 22:11:22
这是一个包括毫秒的秒表,小弟有点问题,以下是我编的程序,于嘛不行啊

dim a as string, b as string, c as string, d as string
dim i as integer

private sub command1_click()
timer1.enabled = true
end sub

private sub form_load()
timer1.enabled = false
end sub

private sub timer1_timer()
i = i + 1
a = format(i mod 1000, "000")
b = format(i \ 1000 mod 60, "00:")
c = format(i \ 60000 mod 60, "00:")
d = format(i \ 3600000, "0:")
text1.text = d & c & b & a
end sub

这样是不准确的,这样根据不同电脑处理器的性能不同,运算速度是不一样的.需要用到一个额外的类,到网上搜一下,好像那个类叫StopWatch,精确到毫秒
代码如下
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CStopWatch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'
' Win32 API declarations.
'
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Function timeGetDevCaps Lib "winmm.dll" (lpTimeCaps As TIMECAPS, ByVal uSize As Long) As Long
'
' API Structure definitions.
'
Private Type TIMECAPS
wPeriodMin As Long
wPeriodMax As Long
End Type
'