Using the immediate window to do some debugging, I came across the following which I have simplified for the purpose of this question:
running this command:
?20000*2
produces an 'overflow' error. Let's assume this is because we haven't declared a data type, and VBE has assumed Integer
- the result falls outside the boundaries of a signed integer and therefore an overflow occurs.
However if I run:
?39999+1
I get 40000
as expected.
Is this because I've initially started with a Long
instead of an Integer
(i.e. 20,000 vs 39,999)? And therefore memory is allocated based on the initial input data rather than the calculation result?