Did you ever wonder if one way of doing something was faster than another? If so then the following shows you how to use the GetTickCount API to time any process and find out. This is much more accurate than using a timer.
VB Code:
Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long ' Place this code in any Sub or Function Dim lngStart As Long Dim lngFinish As Long Dim lngCounterOne As Long Dim lngCounterTwo As Long ' Record the start "time" lngStart = GetTickCount() ' Some process that you want to time For lngCounterOne = 1 To 1000000 For lngCounterTwo = 1 To 5 Next lngCounterTwo Next lngCounterOne ' Record the finish "time" lngFinish = GetTickCount() ' Display the difference MsgBox CStr(lngFinish - lngStart)




Reply With Quote