Let's say I have a function that takes an Integer value ByRef, like this:
Function myFunc(ByRef funcVal As Integer)
funcVal = funcVal + 1
End Function
And let's suppose I call it like this:
Dim myVal as Integer
myVal = 5
Call myFunc(myVal)
As I understand it, the computer has allocated space for my myVal variable and put the value 5 in that space. When I call myFunc, the computer basically passes a pointer to that location to myFunc, so that when myFunc increments funcVal, it is actually incrementing the same location, so myVal is also incremented.
But what happens if instead I call myFunc like this:
Call myFunc(5)
Does the computer still give myFunc a pointer, and if so a pointer to what? Or does it have to assign some fresh space to funcVal (instead of just using the same space as myVal like it did in my previous example)?
I suppose there's also a related question here - how does VBA handle literal values in the code?
Many thanks!