Solved

Wrapping of GetTickCount in VB

Posted on 2002-05-20
6
1,222 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Expert Comment

by:mirtol
Comment Utility
It will go like

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

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Window placement 17 64
Help in WHSCRIPT 9 41
Write data from SQL to CSV file - position 1 45
DIR issue 7 46
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

16 Experts available now in Live!

Get 1:1 Help Now