beside using the Timer control, you also can you the Win32 API function as below:
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim StartTime As Long ' in Miliseconds
Dim EndTime As Long ' in Miliseconds
Dim TotalDuration As Long ' in Miliseconds
Private Sub Command1_Click()
StartTime = GetTickCount
End Sub
Private Sub Command2_Click()
EndTime = GetTickCount
TotalDuration = EndTime - StartTime
End Sub
If you feel the above method does not meet you require precision, then you can use the QueryPerformanceFrequency and QueryPerformanceCounter Win32 API function, but this is more complex than the GetTickCount that I show above. For this function you need to declare the following Types:
Private Type LARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Hope this can speed up your program performance.
Edited by Chris on 03-09-2000 at 12:48 PM





Reply With Quote