Function ElapsedTime(tStart As Variant, tStop As Variant) As String
' **************************************************************
' Function Name : ElapsedTime *
' Created By : Herry Hariry Amin *
' Email : h2arr@cbn.net.id *
' Language : VB4, VB5, VB6 *
' Example : sYourVariable = ElapsedTime _
(tStartTime,tStopTime)
'Notes: : Times passed to this function should be
' : in valid format (e.g., hh:mm.ss). Otherwise,
' : function will return 0:00:00
' ****************************************************************
On Error GoTo END_ELAPSEDTIME
Dim dtr, dtl, jml As Long
dtl = (Hour(tStart) * 3600) + (Minute(tStart) * 60) + (Second(tStart))
dtr = (Hour(tStop) * 3600) + (Minute(tStop) * 60) + (Second(tStop))
If tStop < tStart Then
jml = 86400
Else
jml = 0
End If
jml = jml + (dtr - dtl)
ElapsedTime = Format(Str(Int((Int((jml / 3600)) Mod _
24))), "00") + ":" + Format(Str(Int((Int((jml / 60)) Mod _
60))), "00") + ":" + Format(Str(Int((jml Mod 60))), "00")
END_ELAPSEDTIME:
End Function
***
Sample How to Use:
dim start as variant = now()
debug.print ElapsedTime(start, now)
No comments:
Post a Comment