Solved

Wrapping of GetTickCount in VB

Posted on 2002-05-20
6
1,232 Views
Last Modified: 2009-05-24
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!!!

0
Comment
Question by:talia
6 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 250 total points
ID: 7021199
Hi talia,

VB longs are signed so it will wrap after 24 days, if you want the complete 49 days put it the GetTickCount into a currency variable and you've to detect the wrapping around to zero yourself

HTH:O)Bruintje
0
 
LVL 15

Expert Comment

by:lyonst
ID: 7021285
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.
0
 
LVL 15

Expert Comment

by:lyonst
ID: 7021299
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:mirtol
ID: 7021994
It will go like

0 ... 2147483647, -2147483648, -2147483647, -2147483646 ... -1, 0 etc
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7818276
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
0
 

Expert Comment

by:SpideyMod
ID: 7909747
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now