View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default ParamArray debug anomaly

"Alan Beban" wrote in message
...
Peter T wrote:
But that's the same non-anomaly as the last one :-)

it's the same as trying to do -
Redim arr(1 to 4, 1 to 4)
Typename(arr(1)) ' Subscript out of range

but could do -
TypeName(Application.Index(x(0), 1)) ' Variant()

which is where I came in!

Regards,
Peter T


I'm not sure how worthwile it is for me to be prolonging this thread,
but then not everything I do is worthwile :-)

The only thing that now remains that strikes me as anomalous is that the
Locals window seems to be indicating that x(0)(1) is a variable of the
Variant type, i.e., it shows

Expression Type
x Variant(0 to 0)
x(0) Variant/Variant/Variant(1 to 4, 1 to 4)
x(0)(1) Variant(1 to 4)

but that doesn't seem to be the case.

Regards,
Alan Beban


I still don't see any anomaly in attempts to reference x(0)(1) with Ubound,
typename, vartype (cos' it's a one row of a multi-row array), but curiously
I too am starting to see something odd in Locals. In particular an
inconsistency between looking at the same array in Locals vs Watch.

Sub test()
Dim a
Dim b()
Dim c(): ReDim c(1 To 4, 1 To 3) As Variant
Dim d: ReDim d(1 To 4, 1 To 3) As Variant

a = Range("a1:c4")
b = Range("a1:c4")
c = Range("a1:c4")
d = Range("a1:c4")
res = foo(a, b, c, d)

End Sub
Function foo(ParamArray x())
Dim y
Dim z()

y = x
z = x

End Function

Looking in Locals at x(0) and x(3) both show
Variant/Variant/Variant(1 to 4, 1 to 3)

However, looking at same in Watch, x(0) and x(3) both show
Variant/Variant(1 to 4, 1 to 3)

x(1) and x(2) show the Variant/Variant in both Locals and Watch

I also compared y & z in Locals vs Watch

Locals
y - Variant/Variant(0 to 3) ' as expected
z - Variant(0 to 3) ' as expected

Watch
y - Variant/Variant(0 to 3) ' as expected
z - Variant/Variant(0 to 3) ' NOT as expected

y(n) and z(n) are all Variant/Variant(1 to 4,1 to 3) in both Locals &
Watch, ie not quite same as some of the equivalents in x

Indeed odd, not sure any of this has any implications, probably not ?

I think we can put it down to a quirk !

Regards,
Peter T