Re: gettickcount returns a negative number???
- From: "Karl E. Peterson" <karl@xxxxxxxx>
- Date: Tue, 23 Aug 2005 17:19:56 -0700
pithhelmet wrote:
> My application uses gettickcount to build a unique string
> that is used to communicate with a host system.
Use Hex$(GetTickCount()) instead, in that case. Keep reading if you care why I say
that.
> everything works fine but now i'm receiving a negative
> number from the API call when the system passes the x number of
> days mark....
>
> i tried to recreate the problem using a loop in VB6
> but the program errors out OK when it goes too far -
>
> so why does the API return a negative number?
It doesn't. But that's how VB, and you, choose to view it. Yes, it's a choice. VB
Long variables use the highest bit to indicate sign. But Windows is handing you an
unsigned DWORD value. So, if the highbit is set, VB thinks it's negative. It's up
to you to see beyond that.
&h00000000-&h7FFFFFFF "positive"
&h80000000-&hFFFFFFFF "negative"
If you really gotta have it in decimal, rather than hex, you can "convert" it like
this:
Private Function ULong(ByVal Int32 As Long) As Currency
Const OFFSET_4 As Currency = 4294967296@
If Int32 < 0 Then
ULong = CCur(Int32) + OFFSET_4
Else
ULong = Int32
End If
End Function
Later... Karl
--
Working Without a .NET?
http://classicvb.org/petition
.
- Follow-Ups:
- Re: gettickcount returns a negative number???
- From: Rick Rothstein [MVP - Visual Basic]
- Re: gettickcount returns a negative number???
- From: MP
- Re: gettickcount returns a negative number???
- References:
- gettickcount returns a negative number???
- From: pithhelmet
- gettickcount returns a negative number???
- Prev by Date: Re: gettickcount returns a negative number???
- Next by Date: API to get date/time from another machine (i.e. net time \\hostname)
- Previous by thread: Re: gettickcount returns a negative number???
- Next by thread: Re: gettickcount returns a negative number???
- Index(es):
Relevant Pages
|