Array Argument Parenthesis
Doesn't the second one error for you, expecting an index number?
It matters if it is re-dimmed, but that may be what you want. If it is
passed ByRef and you redim it., the caller will see the changes. For
instance
Public Sub Test()
Dim ary
ary = Array(1, 2, 3)
MsgBox ary(UBound(ary))
Call Called(ary)
MsgBox ary(UBound(ary))
End Sub
Sub Called(ByRef ary As Variant)
ReDim Preserve ary(UBound(ary) + 1)
ary(UBound(ary)) = 4
End Sub
but if paseed ByVal, it won't. For instance
Public Sub Test()
Dim ary
ary = Array(1, 2, 3)
MsgBox ary(UBound(ary))
Call Called(ary)
MsgBox ary(UBound(ary))
End Sub
Sub Called(ByVal ary As Variant)
ReDim Preserve ary(UBound(ary) + 1)
ary(UBound(ary)) = 4
End Sub
--
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"Neal Zimm" wrote in message
...
An array is created in a sub, call it TestAy
it's passed to a call. What is the technical difference between A and B?
call SubA(TestAy) ' no parens follow
call SubB(TestAy()) ' parens follow
Does it matter if TestAy is ReDim'd in the called sub the parens ?
Thanks
--
Neal Z
|