I want to pass the values of an array to a function that accepts these parameters. When I do it based on the code provided, I get an error telling me: "ByRef argument type mismatch" I understand that my array is declared as variant, but the values I pass to it, are from the appropriate data type for the function to accept based on VarType(arrValues(1 - 3)) so what should be changed to the code?
This is a simplyfied version of the code I will be using lateron, where the function will actual return something usefull and will receive many more parameters.
Sub CallFunctionWithArray()
Dim arrValues(1 To 3) As Variant
arrValues(1) = "One"
arrValues(2) = 19 - 11 - 2019
arrValues(3) = 25
Call ReturnValuesOfArray(arrValues(1), arrValues(2), arrValues(3))
End Sub
Function ReturnValuesOfArray(ValueOne As String, ValueTwo As Date, ValueThree As Integer)
Debug.Print ValueOne
Debug.Print ValueTwo
Debug.Print ValueThree
End Function
Would expect the code to run and print the values of the passed array to de immediate window in this case.