'################################################################ |
'36.函数作用:文字格式的时间(分:秒)转化为数字格式(秒) |
'################################################################ |
|
Function TxtSecondToNumber(strTxt As String) |
'' The format of strTxt is mm:ss.?? |
Dim iFirst As Integer |
strTxt = Trim(strTxt) |
iFirst = InStr(1, strTxt, ":") |
If iFirst > 0 Then |
TxtSecondToNumber = Val(Left(strTxt, iFirst - 1)) * 60 + _ |
Val(Mid(strTxt, iFirst + 1)) |
Else |
TxtSecondToNumber = Val(strTxt) |
End If |
End Function |
我在“示例”工作表中A1单元格输入“txtsecondtonumber("1:55")后单元格A1显示115,这是正确的,因为1分55秒本来就等于115秒,但是我在A2单元格输入”1:55“,在B2单元格输入"txtsecondtonumber(A2)"后却显示0.079861111,为什么不显示115呢,为此我把A2单元格设置成了时间显示格式,结果还是这样,这是为什么呢,请高手指点,先谢谢了。