VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Simple ElapsedTime function in hh:mm:ss format.

by Maurizio Ammannato (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 21st January 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Simple "ElapsedTime" function in "hh:mm:ss" format.

Rate Simple ElapsedTime function in hh:mm:ss format.



Dim TimerB as Long
TimerB=Timer
'Get starting TIMER value
sleep 5000
debug.print ElapsedTime(TimerB)
End
End Sub

Public Function ElapsedTime(ByVal StartTimer As Long) As String
'where StartTimer is the starting TIMER value
Dim lh, lm, ls, TimerD As Long
TimerD = Int(Timer - StartTimer)
lh = Int(TimerD \ 3600)
lm = Int((TimerD - (lh * 3600)) \ 60)
ls = Int(TimerD - (lh * 3600) - lm * 60)
ElapsedTime = Right("0" + Trim(Str(lh)), 2) + ":" + Right("0" + Trim(Str(lm)), 2) + ":" + Right("0" + Trim(Str(ls)), 2)
End Function

Download this snippet    Add to My Saved Code

Simple ElapsedTime function in hh:mm:ss format. Comments

No comments have been posted about Simple ElapsedTime function in hh:mm:ss format.. Why not be the first to post a comment about Simple ElapsedTime function in hh:mm:ss format..

Post your comment

Subject:
Message:
0/1000 characters