views:

2030

answers:

1

I need to do calculations (division or multiplication) with very large numbers. Currently I am using Double and getting the value round off problems. I can do the same calculations accurately on C# using Decimal type. I am looking for a method to do accurate calculations in VB6.0 and I couldn't find a Decimal type in VB6.0.

What is the data type used for doing arithmetic calculations with large values and without getting floating point round off problems?

Thanks

+8  A: 

Depending on your data type, you can always use Currency, which is like Decimal(19,4), or 15 digits to the left of the decimal point, and 4 to the right.

In VB6, try using the variant datatype, and casting your numbers to that using CDec, as in:

Dim myDec As Variant
myDec = CDec(1.234)

See if that works.

Scott Whitlock
Thanks Scott. Let me try it out
Appu
Decimal is a perfectly legal Variant subtype in COM, and is *sort of* supported by VB6 with the CDec typecast. Obviously Currency is more convenient to use in VB6 due to full language support.
Christian Hayter