office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

Access将秒数转化为时分秒00:00:00的格式

2017-12-29 16:46:00
Trynew
转贴
5691

有时我们在其他软件中导出得到一串秒数。希望把改秒数转化为时分秒00:00:00的格式

这里需要自定义一个函数去转换

Function SecToTime(dblSecond As Double) As String
    SecToTime = Format((Int(dblSecond) / 60 / 60 / 24), "HH:MM:SS")
    If Int(dblSecond) <> dblSecond Then SecToTime = SecToTime & Round(dblSecond - Int(dblSecond), 2)
    SecToTime = IIf(Left(SecToTime, 6) = "00:00:", Mid(SecToTime, 7), IIf(Left(SecToTime, 3) = "00:", Mid(SecToTime, 4), SecToTime))
End Function



在窗体中调用该函数

Private Sub Command4_Click()
    Me.Text2 = SecToTime(Me.Text0)
End Sub



效果图:

    分享