K
Karitaat
Hi,
no question, maybe just an answer to some.
On the basis of Karl E. Peterson's excellent CStopWatch class module
(can be imported without a problem into VBA)
I have written myTimer that allows you to set a number of Timed Points
You need three different calls to myTimer in your own routine(s):
myTimer "",1 'to start myTimer
myTimer "Some text here" 'to set a Timed Point
myTimer "Some other text" 'to set another Timed Point, etc
myTimer "",0 'to stop myTimer and show the Timed Points
myTimer acts as a Debug statement (it shows the flow of a routine)
and shows the difference (in milliseconds) between Timed Points
Cheers,
Karitaat
Public Static Sub myTimer(sText As String, Optional iStartStop As
Integer = -1)
'to be used with Karl E. Peterson's CStopWatch class
'see: http://vb.mvps.org/samples/project.asp?id=StopWatch
'pw; oct 2006
Select Case iStartStop
Case 1 'Starts the timer
Dim tmr As Object
Set tmr = New CStopWatch
Dim lTimer(1 To 50) As Long 'for Elapsed Times
Dim sTimer(1 To 50) As String 'for names of the Timed Points
Dim iTimer As Integer 'Pointer in lTimer and sTimer
iTimer = 0
tmr.Reset
Case 0 'Stops the timer and show the Timed Points
Dim nTimedPoints As Integer 'number of timed points
Dim diffTimer As Long 'time difference between points
nTimedPoints = iTimer
diffTimer = lTimer(1)
'Show the Timed Points
For iTimer = 1 To nTimedPoints
If iTimer > 1 Then
diffTimer = lTimer(iTimer) - lTimer(iTimer - 1)
End If
MsgBox Prompt:=sTimer(iTimer) & " " & CStr(diffTimer), _
Buttons:=vbInformation, Title:="myTimer"
Next iTimer
Set tmr = Nothing
Case Else 'Sets a Timed Point
iTimer = iTimer + 1
sTimer(iTimer) = sText
lTimer(iTimer) = tmr.Elapsed
End Select
End Sub 'myTimer
no question, maybe just an answer to some.
On the basis of Karl E. Peterson's excellent CStopWatch class module
(can be imported without a problem into VBA)
I have written myTimer that allows you to set a number of Timed Points
You need three different calls to myTimer in your own routine(s):
myTimer "",1 'to start myTimer
myTimer "Some text here" 'to set a Timed Point
myTimer "Some other text" 'to set another Timed Point, etc
myTimer "",0 'to stop myTimer and show the Timed Points
myTimer acts as a Debug statement (it shows the flow of a routine)
and shows the difference (in milliseconds) between Timed Points
Cheers,
Karitaat
Public Static Sub myTimer(sText As String, Optional iStartStop As
Integer = -1)
'to be used with Karl E. Peterson's CStopWatch class
'see: http://vb.mvps.org/samples/project.asp?id=StopWatch
'pw; oct 2006
Select Case iStartStop
Case 1 'Starts the timer
Dim tmr As Object
Set tmr = New CStopWatch
Dim lTimer(1 To 50) As Long 'for Elapsed Times
Dim sTimer(1 To 50) As String 'for names of the Timed Points
Dim iTimer As Integer 'Pointer in lTimer and sTimer
iTimer = 0
tmr.Reset
Case 0 'Stops the timer and show the Timed Points
Dim nTimedPoints As Integer 'number of timed points
Dim diffTimer As Long 'time difference between points
nTimedPoints = iTimer
diffTimer = lTimer(1)
'Show the Timed Points
For iTimer = 1 To nTimedPoints
If iTimer > 1 Then
diffTimer = lTimer(iTimer) - lTimer(iTimer - 1)
End If
MsgBox Prompt:=sTimer(iTimer) & " " & CStr(diffTimer), _
Buttons:=vbInformation, Title:="myTimer"
Next iTimer
Set tmr = Nothing
Case Else 'Sets a Timed Point
iTimer = iTimer + 1
sTimer(iTimer) = sText
lTimer(iTimer) = tmr.Elapsed
End Select
End Sub 'myTimer