多媒体时钟,可以想象是非常精确的
Public Const TIME_PERIODIC = 1
Public Const TIME_ONESHOT = 0
Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
timer很不精确。
一个办法是设timer的interval=1,在其timer事件中定义一个静态变量,然后用gettickcount api来获取tick count(精确至毫秒),然后……
Sub Timer1_Timer()
Static lTmp As Long, Static lLast10Tick As Long, lTick As Long
lTick = GetTickCount()
If lTick - lLast10Tick = 10 Then '10 ms
Call Procedure() 'Procedure 为调用的过程名
lLast10Tick = lTick
End If
End Sub