Declare Function GetTickCount Lib "kernel32.dll" () As Long
GetTickCount determines how much time has elapsed since Windows was last started. The time is measured in milliseconds, although the actual resolution of the function's output depends on that of the system timer itself. Therefore, it may not be perfectly accurate to the millisecond. Because of the limitations of the 32-bit integer data type, the reported elapsed time wraps back to zero after about 49.7 days of continuous operation.
The function returns the number of milliseconds that have passed since Windows was last started.
None.
None.
' This code is licensed according to the terms and conditions listed here.
' Determine about how much time it takes for Visual
' Basic to compute the square root of a large number. The elapsed
' time for that operation is displayed in seconds.
Dim starttime As Long ' timer value before the calculation
Dim endtime As Long ' timer value after the calculation
Dim result As Double ' receives result of square root operation
' Find how much time has passed since Windows was started.
starttime = GetTickCount()
' Calculate the square root of a large number.
result = Sqr(54761)
' Find how much time has now passed since startup.
endtime = GetTickCount()
' The difference between starttime and endtime is the time it took
' to calculate the square root.
Debug.Print "The calculation took"; (endtime - starttime) / 1000; "seconds."
Back to the Function list.
Back to the Reference section.
Last Modified: March 19, 2000
This page is copyright © 2000 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/gettickcount.html