Public Type HourMinuteSecondMS
Hours As Integer
Mins As Byte
Secs As Byte
MS As Integer
End Type
Public Function GetHMSfromMS(ByVal Milliseconds As Long) As HourMinuteSecondMS
GetHMSfromMS.Hours = CInt(Milliseconds \ 3600000)
GetHMSfromMS.Mins = CByte((Milliseconds Mod 3600000) \ 60000)
GetHMSfromMS.Secs = CByte((Milliseconds Mod 60000) \ 1000)
GetHMSfromMS.MS = CInt(Milliseconds Mod 1000)
End Function
Public Function GetStrFromMS(ByVal Milliseconds As Long, Optional ByVal AlwaysFull As Boolean) As String
Dim lngHours As Long, lngMins As Long, lngSecs As Long, lngMS As Long
Dim blnHours As Long, blnMins As Long
lngHours = Milliseconds \ 3600000
blnHours = (lngHours > 0) Or AlwaysFull
lngMins = (Milliseconds Mod 3600000) \ 60000
blnMins = (lngMins > 0) Or blnHours
lngSecs = (Milliseconds Mod 60000) \ 1000
lngMS = Milliseconds Mod 1000
If blnHours Then
GetHMSfromMS = CStr(lngHours) & ":" & Format$(lngMins, "00") & ":" & _
Format$(lngSecs, "00") & "." & Format$(lngMS, "000")
ElseIf blnMins Then
GetHMSfromMS = Format$(lngMins, "00") & ":" & _
Format$(lngSecs, "00") & "." & Format$(lngMS, "000")
Else
GetHMSfromMS = Format$(lngSecs, "00") & "." & Format$(lngMS, "000")
End If
End Function