Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
' called with
' Sleep 10000
' GetTickCount starts at 0 when windows starts up
Declare Function GetTickCount Lib "user32" () As Long
' it is about 80+ % faster than TIMERcalls if speed is of the essence
' usage:
' Dim lTimer1 as Long
' lTimer1 = GetTickCount()
' a handy "turn timer into human readable clock"
Dim strTempString As String
strTempString = sfunGetTime(Timer)
Public Function sfunGetTime(ByVal sglTime As Single) As String
' takes time (sglTime) and converts it to "user friendly"
' display of hours:minutes:seconds.milliseconds
' as hh:mm:ss.lll
'global the vars to speed the function sfunGetTime
'Global sglX As Single
'Global sglY As Single
'Global sglZ As Single
'Global sglV As Single
'Global strHrs As String
'Global strMin As String
'Global strSec As String
'Global strMSec As String
On Error GoTo sfunGetTime_Error
sglX = Int(sglTime / 3600#)
strHrs = Format$(sglX, "00")
sglY = Int(((sglTime / 3600#) - Int(sglTime / 3600#)) * 60#)
strMin = Format$(sglY, "00")
sglZ = Int(sglTime - (sglX * 3600# + sglY * 60#))
strSec = Format$(sglZ, "00")
sglV = sglTime - (sglX * 3600# + sglY * 60#) - Int(sglTime - (sglX * 3600#+ sglY * 60#))
strMSec = Format$(sglV * 100#, "00")
sfunGetTime = Mid(strHrs & ":" & strMin & ":" & strSec & "." & strMSec, 1, 11)
Exit Function
sfunGetTime_Error:
sfunGetTime = "ERROR"
' whatever you normally do in error handling
End Function
Another way would be to set up a timer control to cycle once every 1000 milliseconds,
set/increment a LONG variable and count seconds from the start time.