I'm trying to make a function flexible where it can accept both a ParamArray or an Array. I'm having problems with result2 (getting a mismatch error). What's the proper way to work around this?
VBA Code:
Sub Test()
Dim arr As Variant, result1 As String, result2 As String
arr = Array("A", "B", "C")
result1 = Test2("A", "B", "C")
result2 = Test2(arr)
MsgBox result1
MsgBox result2
End Sub
Function Test2(ParamArray arg() As Variant) As String
Dim element As Variant
Dim str As String
For Each element In arg
str = str & element
Next
Test2 = str
End Function