VB 时长转换/时间转换,VB 时长转换,VB 时间转换,VB 时长,VB 时间,VB 把时长转换为*天*时*分*秒,VB 时长转换为*天*时*分*秒,VB 时长转为*天*时*分*秒,VB 时间转为*天*时*分*秒,VB *天*时*分*秒,VB TimeToData。

VB 时长转换/时间转换,VB 把时长转换为*天*时*分*秒:

Public Function TimeToData(Ms) As String                                        '时长转换/时间转换
    Dim D, S, F, M                                                              '天,时,分,秒
    M = Ms / 1000                                                               '总秒数
    If M > 86400 Then                                                           '如果超过1天
        D = M / 86400
        If InStr(D, ".") > 0 Then D = Left(D, InStr(D, ".") - 1)                '小时
        If Len(D) < 2 Then D = "0" & D                                          '补位
    Else
        D = "00"
    End If
    M = M - D * 86400                                                           '减去天数后剩下的秒数
    If M > 3600 Then                                                            '如果超过1小时
        S = M / 3600
        If InStr(S, ".") > 0 Then S = Left(S, InStr(S, ".") - 1)                '小时
        If Len(S) < 2 Then S = "0" & S                                          '补位
    Else
        S = "00"
    End If
    M = M - S * 3600                                                            '减去小时后剩下的秒数
    If M > 60 Then                                                              '如果超过1分钟
        F = M / 60
        If InStr(F, ".") > 0 Then F = Left(F, InStr(F, ".") - 1)                '分钟
        If Len(F) < 2 Then F = "0" & F                                          '补位
    Else
        F = "00"
    End If
    M = CInt(M - F * 60)                                                        '减去分钟后剩下的秒数
    If InStr(M, ".") > 0 Then M = Left(M, InStr(M, ".") - 1)
    If Len(M) < 2 Then M = "0" & M                                              '补位
    TimeToData = D & "天" & S & "时" & F & "分" & M & "秒"
End Function

MsgBox TimeToData(999999999)