Saladsamurai
11-16-2009, 11:02 AM
I know I have seen this done before, but I can't seem to figure out how.
I want to see how long it takes to run a certain For loop by doing something to the effect of:
Sub StopWatch()
Dim StartTime As Variant
Dim TimeElapsed As Variant
Dim i As Long
i = 0
StartTime = Time()
Do While i < 100000000
i = i + 1
Loop
TimeElapsed = Time() - StartTime
MsgBox TimeElapsed
End Sub
Any ideas? This returns a number that is clearly way too small (on my machine) to be the time elapsed. This Loop took at least 3 seconds to complete but the Value MsgBoxed was less than 1.
The Time() function returns a Variant.
I want to see how long it takes to run a certain For loop by doing something to the effect of:
Sub StopWatch()
Dim StartTime As Variant
Dim TimeElapsed As Variant
Dim i As Long
i = 0
StartTime = Time()
Do While i < 100000000
i = i + 1
Loop
TimeElapsed = Time() - StartTime
MsgBox TimeElapsed
End Sub
Any ideas? This returns a number that is clearly way too small (on my machine) to be the time elapsed. This Loop took at least 3 seconds to complete but the Value MsgBoxed was less than 1.
The Time() function returns a Variant.