Importing large numbers

  • Thread starter Thread starter Jane Fornoff
  • Start date Start date
J

Jane Fornoff

I would like to import a text file containing large
integers (of the order 10**15) into Access in a standard
format, rather than floating-point. (When I perform
arithmetic operations on the imported integers, I am
getting odd results, which I suspect are due to rounding
errors). I cannot find any way of specifiying the format
during the import.

Any suggestions?
Thanks, Jane

I am using Access 2000 (9.0.6926 SP-3) on WIndows XP
(5.1.2600 Service Pack 1 Build 2600)
 
Hi Jane,

Access and VBA don't support huge integers as such. If your numbers
aren't too big you could try the Currency data type, which is a 64-bit
integer with fixed scaling to allow 4 decimal places. The largest number
it can store is about 9E15 (922,337,203,685,477.5807 to be precise).

If that's not enough, import your integers into text fields. Probably
there's a VB library somewhere with arithmetic operations for
arbitrarily large integers. If you can't find one, you could use string
operations to scale the numbers into Currency variables for the
arithmetic, and back to strings afterwards, something like this:

Dim strN1 As String, curN1 As Currency

strN1 = "123456789012345"
If Len(strN1) < 5 Then
'pad with zeroes if too short
strN1 = Right("00000" & strN1, 5)
End If
'insert decimal point and convert
curN1 = CCur(Left(strN1, Len(strN1)-4) _
& "." & Right(strN1, 4)

'do maths
...

strN1 = Format(curN1, "0.0000")
'strip leading zeros and decimal point
...
 
Back
Top