John said:
Hi
Is it possible to pass array of strings as parameter and if so how can I
figure in the called SUB the number of elements in the passed array?
Sure you can pass an array as a parameter. For example:
'----- start of code -----
Sub ProcessArray(MyArray() As String)
' This procedure accepts an array of strings as an argument.
Dim I As Long
Debug.Print "MyArray has " & UBound(MyArray) - LBound(MyArray) + 1 & "
elements."
For I = LBound(MyArray) To UBound(MyArray)
Debug.Print MyArray(I)
Next I
End Sub
Sub ProcessArrayDemo()
' This procedure will call ProcessArray.
Dim strArray() As String
strArray = Split("A,B,C", ",")
ProcessArray strArray
End Sub
'----- end of code -----
Note that the above code allows only for a one-dimensional array. Also, it
may sometimes be useful to allow the procedure to accept a Variant
containing an array, rather than an array itself. That may give a little
more flexibility.