Solved

Wrapping of GetTickCount in VB

Posted on 2002-05-20
6
1,258 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 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
Industry Leaders: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 69
MS Date Picker 64 bit 32 bit issue 12 63
How to measure sizes and angles in scanned images ? 3 87
Send outlook email from VBS Script 2 58
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 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