Option Explicit
Sub TEST_Byg_Time()
'' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'' Purpose : Tester
'' Written : 15-Oct-2010 by Andy Wiggins, BygSoftware.com
Byg_Time "START"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "ELAPSED", "XX"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "ELAPSED", "Second ELAPSED"
Application.Wait Now + TimeValue("0:00:03")
Byg_Time "ELAPSED", "Second ELAPSED"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "FINISH"
End Sub
Sub TEST_Byg_Time_Initials()
'' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'' Purpose : Tester
'' Written : 15-Oct-2010 by Andy Wiggins, BygSoftware.com
Byg_Time "S"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "E", "XX"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "E", "Second ELAPSED"
Application.Wait Now + TimeValue("0:00:03")
Byg_Time "E", "Second ELAPSED"
Application.Wait Now + TimeValue("0:00:02")
Byg_Time "F"
End Sub
Sub TEST_Byg_Time2()
Byg_Time "START"
End Sub
Sub TEST_Byg_Time3()
Byg_Time "ELAPSED"
End Sub
Sub TEST_Byg_Time4()
Byg_Time "FINISH"
End Sub
Static Sub Byg_Time(aStr_Arg As String, Optional aStr_Comment As String)
'' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'' Purpose : *
'' Written : 15-Oct-2010 by Andy Wiggins, BygSoftware.com
''
'' : Static: Indicates that the Sub procedure's local variables are preserved between calls.
'' : The Static attribute doesn't affect variables that are declared outside the Sub,
'' : even if they are used in the procedure.
''
'' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
''
Dim lDbl_Start As Double
Dim lDbl_Stop As Double
Dim lDbl_Inter As Double
Dim lDbl_CurTime As Double
Dim lDbl_NetTime As Double
Dim lStr_NetTime As String
Static lDbl_LastTime As Double
Dim lStr_CurTime As String
lDbl_CurTime = Now - lDbl_Start
lStr_CurTime = Format(lDbl_CurTime, "hh:mm:ss")
lDbl_NetTime = lDbl_CurTime - lDbl_LastTime
lDbl_LastTime = lDbl_CurTime
lStr_NetTime = Format(lDbl_NetTime, "hh:mm:ss")
Select Case UCase(aStr_Arg)
Case "START", "S"
lDbl_Start = Now()
lDbl_LastTime = 0
Debug.Print "START", Now, lStr_CurTime, aStr_Comment
Case "ELAPSED", "E"
If lDbl_Start > 0 Then
Debug.Print "ELAPSED", Now, lStr_CurTime, lStr_NetTime, aStr_Comment
Else
'' ANW 24-Nov-2010 12:04
'' lDbl_Start doesn't exist, so this forces the start
lDbl_Start = Now()
Debug.Print "ELAPSED", Now, "Forced start", aStr_Comment
End If
Case "FINISH", "F"
If lDbl_Start > 0 Then
lDbl_Stop = Now()
Debug.Print "FINISH", Now, lStr_CurTime, aStr_Comment
lDbl_Start = 0
Else
Debug.Print "FINISH", Now, "Not started", aStr_Comment
End If
Case Else
Debug.Print "This shouldn't occur"
End Select
End Sub
|