你如何解析一个毫秒数到HH:MM:SS

时间:2011-12-10 16:57:05

标签: basic4android

您能告诉我如何将毫秒数(例如10173510)解析为小时,分钟和秒吗?

这样的形式可能吗? HH:MM:SS

感谢。

更新: 我能够把它关闭但我需要正确格式化数字,因为我需要前导零(0)使结果看起来像这样:01:52:03因为代码显示1:52:3而不是。

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

1 个答案:

答案 0 :(得分:1)

尝试使用数字格式:

示例:

小时= 2
的NumberFormat(小时,2,0)