把秒为单位的时间值转换成用日时秒来表示
请问把秒为单位的时间值转换成用日时秒来表示,如何编程?我编了一个,运行时数值一大就提示"运行错误,溢出".高手赐教!
Option Explicit
Private Sub Form_Load()
Debug.Print GetTimeSTR(1254879542)
End Sub
Private Function GetTimeSTR(ByVal SecondNum As Long) As String
Dim HourNum As Long, MinuteNum As Long
If SecondNum < 0 Then Exit Function
HourNum = SecondNum \ 3600
SecondNum = SecondNum Mod 3600
MinuteNum = SecondNum \ 60
SecondNum = SecondNum Mod 60
GetTimeSTR = CStr(HourNum) & ":" & CStr(MinuteNum) & ":" & CStr(SecondNum)
End Function