I'm searching for a constant like MAXINT in c, for VBA code. I found references only in other languages, and cannot find one for VBA.
If there is no such constant what is the maximum number an int in VBA can hold? I tried 2147483647 but got an overflow error.
VBA does not provide a MAXINT
constant. But you can derive that value easily:
MAXINT = (2 ^ 15) -1
Debug.Print MAXINT
32767
Or you could define it as a Public
constant with this in the Declarations section of a standard module:
Public Const MAXINT As Integer = (2 ^ 15) - 1
Then MAXINT
would be available for the rest of your VBA code in that application.
And for Long Integer
, the maximum value is ...
MAXLONG = (2 ^ 31) -1
Debug.Print MAXLONG
2147483647
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With