|
-
May 5th, 2002, 11:44 PM
#1
Thread Starter
Frenzied Member
How can you get current uptime using GetTickCount?
Heres my current code:
VB Code:
MilliSeconds = GetTickCount
Days = MilliSeconds / 86400000
MilliSeconds = MilliSeconds Mod 86400000
Hours = MilliSeconds / 3600000
MilliSeconds = MilliSeconds Mod 3600000
Minutes = MilliSeconds / 60000
MilliSeconds = MilliSeconds Mod 60000
Seconds = MilliSeconds / 1000
but this has major issues with rounding (IE 1hr 30 mins is displayed as 2 hr 30 min)
anyone know of anything else?
-
May 5th, 2002, 11:58 PM
#2
Hyperactive Member
What Have You Declared MilliSeconds, Days, Hours, Seconds as?
Visual Baisc 6 (SP5)
Windows Xp
-
May 6th, 2002, 12:35 AM
#3
Thread Starter
Frenzied Member
Dim MilliSeconds As Long, Days As Integer
Dim Hours As Integer, Minutes As Integer, Seconds As Integer
should they all be long?
-
May 6th, 2002, 02:29 AM
#4
Fanatic Member
The following seems to work for me.
VB Code:
Dim Days, Hours, Minutes, Seconds As Long
Dim ret As Long
'Get the tickcount
ret = GetTickCount&
Days = ret \ 86400000
Hours = (ret - (Days * 86400000)) \ 3600000
Minutes = (ret - (Days * 86400000) - (Hours * 3600000)) \ 60000
Seconds = (ret - (Days * 86400000) - (Hours * 3600000) - (Minutes * 60000)) \ 1000
MsgBox Days & " Days, " & Hours & " Hours, " & Minutes & " Minutes, " & Seconds & " Seconds."
Martin J Wallace (Slaine)
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
|