Question posted 2008 · +10 upvotes
This declaration causes an overflow in VBA:
Const OVERFLOWS As Long = 10 * 60 * 60
whereas setting the value directly is fine:
Const COMPILES_OK As Long = 36000
How do you persuade VBA to treat literal integers as longs?
Thanks
Accepted answer +13 upvotes
Add the long suffix & to at least one number:
Const OVERFLOWS As Long = 10& * 60 * 60
Note that using the CLNG function to convert the values to long will not work, because VBA does not allow assigning the return value of a function to a constant.
Top vba Q&A (6)
- Difference between Visual Basic 6.0 and VBA +122 (2009)
- VBA – how to conditionally skip a for loop iteration +116 (2011)
- VBA: Test if string begins with a string? +53 (2013)
- html parsing of cricinfo scorecards +47 (2012)
- Code to loop through all records in MS Access +46 (2011)
- Access VBA | How to replace parts of a string with another string +44 (2011)
vba solutions on this site
.