Tuesday, August 23, 2011

Seconds, Minutes, and Hours

Function FormatTime(TimeElapsed As Integer) As String
Dim Seconds As Integer
Dim Minutes As Integer
Dim Hours As Integer

'Find The Seconds
Seconds = TimeElapsed Mod 60

'Find The Minutes
Minutes = (TimeElapsed \ 60) Mod 60

'Find The Hours
Hours = (TimeElapsed \ 3600)

'Format The Time
If Hours > 0 Then
FormatTime = Format(Hours,"00") & ":"
End If
FormatTime = Format(Hours, "00") & ":"
FormatTime = FormatTime & Format(Minutes, "00") & ":"
FormatTime = FormatTime & Format(Seconds, "00")
End Function

0 Comments:

Post a Comment