''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private tstart As Single
Private Enum ElapsedTimeType
ttMilliseconds = 1
ttSeconds = 2
ttMinutes = 3
End Enum
Private Function GetElapsedTime(dwTimeType As ElapsedTimeType) As Single
Dim divisor As Long
Select Case dwTimeType
Case ttMilliseconds: divisor = 1
Case ttSeconds: divisor = 1000
Case ttMinutes: divisor = 60000
End Select
GetElapsedTime = (GetTickCount() - tstart) / divisor
End Function
Private Sub Form_Load()
'Assign the current tick count
'as the tick start point. Failure
'to do this will return the number
'of ticks since Windows was last
'rebooted. (Note: elapsed time is
'stored as a DWORD value in Windows.
'Therefore, the time will wrap around
'to zero if the system is run continuously
'for 49.7 days. If a higher resolution
'timer is required, use a multimedia
'or high-resolution timer.
tstart = GetTickCount()
End Sub
|