Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Wrapping of GetTickCount in VB

Posted on 2002-05-20
6
Medium Priority
?
1,305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 1000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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