|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Function gethour(ByVal str As String)
- Dim aRes(1 To 4, 1 To 1), i&, n#
- Dim reg As New RegExp
- Dim maches As MatchCollection
- With reg
- .Pattern = "((\d*)天)?((\d*)时)?((\d*)分)?((\d*)秒)?"
- Set maches = .Execute(str)
- With maches(0)
- aRes(1, 1) = Val(.SubMatches(1)) * 24
- aRes(2, 1) = Val(.SubMatches(3))
- aRes(3, 1) = Val(.SubMatches(5)) / 60
- aRes(4, 1) = Val(.SubMatches(7)) / 3600
- End With
- End With
- For i = 1 To UBound(aRes)
- n = aRes(i, 1) + n
- Next
- gethour = n
- End Function
复制代码 |
|