1,216
社区成员
发帖
与我相关
我的任务
分享
Dim hms(1 To 4) As String
Dim total As Double
Dim i As Integer
hms(1) = "00:32:12"
hms(2) = "01:32:09"
hms(3) = "08:49:16"
hms(4) = "23:08:06" '注意小时数不能>24
total = 0#
For i = 1 To 4
total = total + CDate(hms(i))
Next
Debug.Print CStr(Fix(total * 24#)) + ":" + Format(Minute(total), "00") + ":" + Format(Second(total), "00")
输出
34:01:43
Private Sub Command1_Click()
Dim s As Date, s1 As Date, s3 As String
s = TimeValue("08:03:00") + TimeValue("20:00:05")
s3 = DateDiff("H", s1, s) & ":" & Right(s, 5)
MsgBox s3
End Sub
Private Sub Command1_Click()
Dim s As Date
Dim s1 As Date
s = TimeValue("08:00:00") + TimeValue("20:00:00")
MsgBox DateDiff("H", s1, s)
End Sub