|
-
May 30th, 2006, 10:29 PM
#1
Re: converting seconds
\ is integer division, so 7600 \ 1000 = 7
/ is normal division, so 7600 / 1000 = 7.6
the format function performs rounding, so you end up with 8 instead of 7.
your function won't work for a couple of reasons (try putting in 77600 for example). Try this:
VB Code:
Private Function ConvertMilliSeconds(ByVal mSec As Long) As String
ConvertMilliSeconds = Format$(mSec \ 3600000, "00") & ":" & _
Format$((mSec Mod 3600000) \ 60000, "00") & ":" & _
Format$((mSec Mod 60000) / 1000, "00.000")
End Function
Last edited by bushmobile; May 30th, 2006 at 11:13 PM.
-
May 30th, 2006, 11:10 PM
#2
Thread Starter
Hyperactive Member
Re: converting seconds
Ok, I rewrote it like so:
VB Code:
Private Function cSeconds(ByVal mSec As Long) As String
mSec = 30000
Select Case mSec
Case Is >= 600, Is < 3600
cSeconds = _
Format$((mSec Mod 3600) \ 60, "00") & ":" & _
Format$(mSec Mod 60, "00")
Case Is < 600
cSeconds = "0:" & _
Format$(mSec Mod 60, "00")
Case Is >= 3600, Is < 36000
cSeconds = _
Format$(mSec \ 3600, "00") & ":" & _
Format$((mSec Mod 3600) \ 60, "00") & ":" & _
Format$(mSec Mod 60, "00")
End Select
End Function
Now there is one problem. With mSec at 30000 it completely ignores the first part of the string (the hours) and it returns "20:00". What is going on? No matter what number I make mSec, it will not show the hours. I tried 3599 which returned "59:59" then 3600 which returned "00:00" then 3601 which returned "00:01"
Why is it not showing the hours?
Prefix has no suffix, but suffix has a prefix.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|