Re: How to pass a 2-D array into a function?



You can't have an array as an argument - you have to use a variant e.g.

Function GetNewValue(strVal As String, mBcdeptID As Variant) As Boolean
  if isarray(mBcdeptID) then msgbox mBcdeptID(0)

End Function

HTH,
Gman

Andrew wrote:
Hello, friends,

I have a 2-D array:

Dim bcdeptID(24, 99) As Integer

Now I need to pass it into a function defined as:

Function GetNewValue(strVal As String, mBcdeptID() As Integer) As Boolean

where mBcdeptID()  is a 1-D array. However, when I programmed as:

If GetNewValue(strVal, bcdeptID(0)) = True Then

I got an error, saying wrong number of dimension.

Then I tried GetNewValue(strVal, bcdeptID(0, 0)) ,  but still no luck.

Help please...

Thanks a lot.

.



Relevant Pages


Loading