Question: I've seen instances of code where info is passed to a function without a temporary variable and I can't figure out how to do it. Here is what I mean:

```
For i = 1 to ubound(arr)
    temp = cool_function(arr(i))
next

```

So in the above it's possible to pass arr(i) directly to the cool\_function. However, when I try that I get a ByRef argument type mismatch. What I have to do instead is the following:

```
For i = 1 to ubound(arr)
    temp2 = arr(i)
    temp = cool_function(temp2)
next

```

I have to assign the value of arr(i) to temp2, then pass temp2 to the function. How can I pass values to functions which are part of an array. I tried putting ByVal in the function but that didn't work.

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*UPDATE\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Problem solved. It was the ByVal that was needed. I made a few typos but I was able to get it to work.

Answer: 
It should work as long as the element type is the same as the argument type.  

So for example you have a function like this:

```
Function cool_function(wild As String)
    '~~> cool stuff here
End Function

```

In your sub, below should work:

```
Sub Test()
    Dim arr() As String
    '~~> populate array somewhere here
    For i = 1 to Ubound(arr)
        temp = cool_function(arr(i))
    Next
End Sub

```
This works for me:

```
Sub arrFunctionTest()

    Dim arrV(3) As Variant

    For i = 1 To 3
        arrV(i) = i
        arrV(i) = cool_Function(arrV, i)
    Next i

    For i = 1 To 3
        Debug.Print arrV(i)
    Next i

End Sub

Function cool_Function(arr As Variant, i) As Integer
    cool_Function = arr(i) * 2
End Function

```