How do you parse a millisecond number into HH:MM:SS
-
13-03-2021 - |
Domanda
Can you tell me how to parse a millisecond number such as 10173510 into hours, minutes and seconds?
Formated like this maybe? HH:MM:SS
Thanks.
Update: I was able to get it close but I need to format the numbers correctly because I need leading zeros (0) to make the results look something like this: 01:52:03 because the code shows 1:52:3 instead.
Sub SeekBarTimeToKeepActive_ValueChanged (Value As Int, UserChanged As Boolean)
Dim intHoursToKeepActive As Int
Dim intMinutesToKeepActive As Int
Dim intSecondsToKeepActive As Int
intHoursToKeepActive = DateTime.GetHour(Value) -19
intMinutesToKeepActive = DateTime.GetMinute(Value)
intSecondsToKeepActive = DateTime.GetSecond(Value)
LabelTimeToKeepActive.Text = "Length of time to keep active: " & _
intHoursToKeepActive & ":" & intMinutesToKeepActive & ":" & intSecondsToKeepActive
End Sub
Soluzione
Try using Number Format:
Example:
Hour = 2
NumberFormat(hour,2,0)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow