T
tbone
I was stumped by this for a bit but finally figured it out. I'm
posting this so that others can benefit from the time I spent. (I'm
using Excel 2003.)
I had a SUBroutine to which I passed a boolean parameter ByRef, so
that it could return a value. However, in testing I found that the
value was NOT being returned as expected.
What I finally realized was that I was invoking the routine using what
sorta looks like a function call, i.e.
SubName (parameter)
Now, I know that's wrong, but here's the rub: VBA did not complain
about the syntax, and in fact the routine was called and the value set
in the routine as expected. The calling logic however did not receive
that updated value.
This kinda feels like a bug to me. Essentially VBA allows incorrect
code to be generated because of a syntax variation. No complaints,
just incorrect operation. Simply removing the parentheses makes the
code work.
So be forewarned!
tbone
posting this so that others can benefit from the time I spent. (I'm
using Excel 2003.)
I had a SUBroutine to which I passed a boolean parameter ByRef, so
that it could return a value. However, in testing I found that the
value was NOT being returned as expected.
What I finally realized was that I was invoking the routine using what
sorta looks like a function call, i.e.
SubName (parameter)
Now, I know that's wrong, but here's the rub: VBA did not complain
about the syntax, and in fact the routine was called and the value set
in the routine as expected. The calling logic however did not receive
that updated value.
This kinda feels like a bug to me. Essentially VBA allows incorrect
code to be generated because of a syntax variation. No complaints,
just incorrect operation. Simply removing the parentheses makes the
code work.
So be forewarned!
tbone