Próbuję napisać funkcję, która akceptuje tablicę jako argument. Tablica może mieć dowolną liczbę elementów.Jak przekazać tablicę do funkcji w VBA?
Function processArr(Arr() As Variant) As String
Dim N As Variant
dim finalStr as string
For N = LBound(Arr) To UBound(Arr)
finalStr = finalStr & Arr(N)
Next N
processArr = finalStr
End Function
Oto jak próbuję wywołać funkcję:
Sub test()
Dim fString as string
fString = processArr(Array("foo", "bar"))
End Sub
dostaję błąd mówiąc:
Compile Error: Type mismatch: array or user defined type expected.
Co robię źle?