How to represent 64-bit integer in VB6?

ADO Field.Value is type Variant. When you retrieve an adBigInt in VB6 the Variant will be of subtype Decimal.


You can use Variant datatype with CDec() conversion.

dim c as variant

' set maximum value of int64
c = CDec("9223372036854775807")

Now you can even use standard vb6 math operations, or string conversion functions on c.

Dim c As Variant, d As Variant

c = CDec("9223372036854775807")

Dim i As Integer

i = 1000
d = 10

Debug.Print c + i
Debug.Print c / d
Debug.Print CStr(c)

Results

 9223372036854776807 
 922337203685477580,7 
9223372036854775807

Just be aware that Decimal type Variant is wider than 64 bits, so you don't get the 'Overflow' on the server side :)

Tags:

Vb6