Function str2time(ByVal tmpstr As String)
On Error GoTo exit_Function
Dim arr As Variant: arr = Split(tmpstr, ",")
Dim I As Long
Dim d As Long: d = 0
Dim h As Long: h = 0
Dim m As Long: m = 0
For I = LBound(arr) To UBound(arr)
If InStr(LCase(arr(I)), "week") > 0 Then
d = d + Val(arr(I)) * 7
ElseIf InStr(LCase(arr(I)), "day") > 0 Then
d = d + Val(arr(I))
ElseIf InStr(LCase(arr(I)), "h") > 0 Then
h = Val(arr(I))
ElseIf InStr(LCase(arr(I)), "min") > 0 Then
m = Val(arr(I))
End If
Next I
str2time = IIf(d > 10, d, "0" & d) & ":" & IIf(h > 10, h, "0" & h) & ":" & IIf(m > 10, m, "0" & m) & ":00"
exit_Function:
End Function
1条答案
按热度按时间sqxo8psd1#
如果您使用vba,则此函数将解决您问题
非常简单,自我解释