passing a multi dimensional array as a parameter, or returning one from a function

C

cristy

Hi,

I am trying to either pass in a multi dimensional array as a parameter
to a function and then fill it up with data, or return one from a
function that has been filled with data.

I am not having any luck with either of these approaches. This is how
I've been trying to use so far:

The signature when I try to pass the multi dimensional array in as a
variable is:

Sub getRatings(ByVal staffMem As String, ByVal sheet As Worksheet,
ByRef ratings())

But when I try and call the function like this:

getRatings(staffMem, ThisWorkbook.Worksheets("Survey Results
26-29.05.06"), ratings)

I get a 'Compile Error, Expected: = ' error

The signature when I try to return the multidimensional array is:

sub getRatings(ByVal staffMem As String, ByVal sheet As Worksheet,
ByRef ratings(,))

This doesn't even compile though with an error of: Compile Error:
Expected: )

Any help would be greatly appreciated

Thanks!
 
L

Luke Alcatel

Cristy,
The "expected =" error is because you have enclosed the arguments in
parentheses when you called your subroutines so VB parses your syntax as a
function and it expects assignment of the return value. You can only
enclose the args of a sub in parentheses if you use "call."

Luke
 
C

cristy

Thanks for that!

I found another (dodgy) way around it, but next time I see that error
at least I know what I've done wrong! :)
 
Top