ActiveX: SLHiResTimer      (Filename: SLHIRTIM.OCX)

The SLHiResTimer ActiveX control is a high-resolution timer. The resolution of the default Timer control that comes with Visual Basic is 55 milliseconds but with SLHiResTimer you will have a resolution of one microsecond (0.000001 seconds). If you need to measure times with high accuracy you can use this control to achive it.

SLHiResTimer uses the QueryPerformanceCounter high-resolution performance counter function in Windows API to get the high
accuracy. Some older hardware do not support high-resolution performance counters, but all modern systems have normally support for these counters.


Methods


Start ()

Starts the high-resolution timer. The elapsed time can be read by calling the GetElapsedTime method.

GetElapsedTime () As Long

Returns the elapsed time in microseconds since the last call of Start.

GetFrequency () As Currency

Returns the frequency (ticks per second) that the high-resolution timer works with. If the installed hardware does not support a high-resolution performance counter this method returns 0.
 


Example

Private Sub CommandStart_Click() ' Start
    SLHiResTimer1.Start
    Label1 = "Has started!"
End Sub

Private Sub CommandRead_Click()
' Read elapsed time
    Dim X As Long
    X = SLHiResTimer1.GetElapsedTime()
    Label1 = "Time so far: " + CStr(X) + " microseconds."
End Sub




SamLogic Home Go Back