There are various ways of fixing this issue, essentially GetTickCount will overlap into the negatives after a certain amount of time has passed(i can’t remember the exact amount of days, but Long is 2.14 billion, and that goes by within like, i believe a week or 2)
There’s also timeGetTime, which will get you a longer duration before the value is overlapped to a negative(47 days).
But, there’s an even better solution. You’d be losing out on support for Windows XP however as Windows XP does not have support for it.
GetTickCount64. this uses the Currency data type in vb6(ULongLong in C++, ULong in .net), it has a max of 9,223,372,036,854,775,807. which lasts for years.
to use this, simply do
Public Declare Function GetTickCount64 Lib "kernel32" () As Currency Function getTick() As Currency getTick = GetTickCount64 * 10000 End Function
Essentially what this does is, return the value from getTickCount64 * 10000. why the multiplication? the value that is received from GetTickCount64 is a floating point value(a LOT smaller than getTickCount), however, if you mutliply by 10k, it returns a solid value, which is what we need.
You CAN use something like a long at this point, but you’ll be getting the same issue again with the rolling over to the negative values.
This essentially solves the issue of trying to handle the rolling over issue, in a few lines of code.
As i said however, you lose the ability to use any program with this code, on Windows XP as WinXP does not have support for it.
Hope this helps!