Question

I need to find a way to put a 19-digit integer (scale of 9 × 10^18) in a Word document. The problem is it needs to run on a 32-bit machine so the LongLong data type will not work.

tried to split into a string array but that won't work either cause I need to do a calculation with it afterwards

How to fix this problem?

Was it helpful?

Solution

If you just need the last five digits and you need those to be a number, you can use code like this:

Dim sEan As String
Dim lLastFive As Long

sEan = "90000000000000012345"
lLastFive = CLng(Right$(sEan, 5))

Debug.Print lLastFive, TypeName(lLastFive)

And you should get

 12345        Long

OTHER TIPS

A large number like the example you provide will fit in a Double type:

Sub Test()
Dim num As Double
Dim lon As Long

num = 9 * 10 ^ 18  '## This should work

lon = 9 * 10 ^ 18  '## This will raise an error.

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top