Question

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
Was it helpful?

Solution

Try using Number Format:

Example:

Hour = 2
NumberFormat(hour,2,0)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top