VBA: What is causing this string argument passed to ParamArray to get changed to a number (that looks suspiciously like a pointer)?
Now this is awesome.
Reproduced on office 2003.
Looks like a compiler bug.
The problem is in this line:
Call c.strange("", v(LBound(v)))
Here the compiler creates a Variant
that holds a 1D array of Variant
's, the only element of which is a pointer instead of the value. This pointer then goes to the strange
function which actually is not strange, it only prints the Variant\Long
value passed to it.
This trick brings the compiler sanity back:
Call c.strange("", (v(LBound(v))))
EDIT
Yes, this magic number is a pointer to the VARIANT structure which is supposed to be passed to the strange
method. The first field of which is 8
, which is vbString
, and the data field contains a pointer to the actual string "a"
.
Therefore, it is definitely a compiler bug... Yet another VB compiler bug in regard of arrays ;)