Let’s say I have any array Trial() As Integer
I have two following variables defined as Integer:
Dim Left As Integer
Dim Right As Integer
Now I am increasing the array index of trial
ReDim Preserve Trial(Left+Right)
Now If My total (Left+Right) exceeds Integer limit the above will give error.
And if redeclared Left as Long then it will work fine.
Actually I want to understand the internal calculation for (Left+Right).
Does it allocate the space for total depending on the datatype of “Left”?
Or it may also depends on datatype of “Right”?
It depends on both. The compiler will examine both variables and determine from both what data type it needs. For example. If you were to add (or multiple or divide) an Integer and a Long then the result will give you a long.