Advertisement
2_2002-2004 Math/ Dates #119438

Format GetTickCount

Format the GetTickCount() API to days, hours, minutes, seconds and miliseconds. Useful to measure time elapsed between two points.

AI

Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kod źródłowy
original-source
Function FormatCount(Count As Long, Optional FormatType As Byte = 0) As String
   Dim Days As Integer, Hours As Long, Minutes As Long, Seconds As Long, Miliseconds As Long
   
   Miliseconds = Count Mod 1000
   Count = Count \ 1000
   Days = Count \ (24& * 3600&)
   If Days > 0 Then Count = Count - (24& * 3600& * Days)
   Hours = Count \ 3600&
   If Hours > 0 Then Count = Count - (3600& * Hours)
   Minutes = Count \ 60
   Seconds = Count Mod 60
   Select Case FormatType
    Case 0
     FormatCount = Days & " dd, " & Hours & " h, " & _
      Minutes & " min, " & Seconds & " s, " & Miliseconds & _
      " ms"
    Case 1
      FormatCount = Days & " days, " & Hours & " hours, " & _
      Minutes & " minutes, " & Seconds & " seconds, " & Miliseconds & _
      " miliseconds"
    Case 2
      FormatCount = Days & ":" & Hours & ":" & _
      Minutes & ":" & Seconds & ":" & Miliseconds
   End Select
End Function

Oryginalne komentarze (3)
Odzyskane z Wayback Machine