Link to home
Start Free TrialLog in
Avatar of talia
talia

asked on

Wrapping of GetTickCount in VB

Hi all.
VB documentation states that getTickCount recycles after about 49 days, which is the range of unsigned long.
“The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days. “ (MSDN)
VB’s long is SIGNED and therefore it seems logical to me that the recycling will either be at half the period:
2,147,483,647 / (1000 * 60 * 60 * 24) = 24.85 days
or that it wraps to the negative range of the long var.

THE QUESTION:
I need to know whether in VB, getTickCount wraps to negative numbers after 24.85 days, and if so, exactly how it is done.
An attached article will add 100 points to the 250 I am giving.
Thanks!!!

ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
http://uptimes.wonko.com/client/changelog.html

'FINALLY found the cause of the bug where the client reported negative uptimes after 24 days. It was Microsoft's fault! For some reason, the Windows GetTickCount() API call returns negative uptimes after 24 days. I wrote some code that does some quick math to fix the problem. It should work fine now.'

Looks like it does return negative values after approx 24 days.

T.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q216641

And also ..

'You get a 32 Bit long which is the number of milliseconds since Windows was started. If you use this for long time periods, this value will have a roll-over after 49 days and 17 hours and start with zero again. After 24 days and 20 hours, this value will turn from positive to negative, because VB dosen't have unsigned Integers.'

Cheers,

T.
Avatar of mirtol
mirtol

It will go like

0 ... 2147483647, -2147483648, -2147483647, -2147483646 ... -1, 0 etc
Avatar of DanRollins
Hi talia,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept bruintje's comment(s) as an answer.

talia, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange