Performance Impact: By Reference or By Value
Assuming that you're not modifying a parameter within a procedure, is there
any performance difference in passing the parameter as 'ByRef' or 'ByVal'.
For example
Dim arr as variant
arr = Array(12,40)
arr = TimesTwo(arr)
Function TimesTwo(ByRef or ByVal arr as variant)
Dim i as integer,arrTemp as variant
Redim arrTemp(ubound(arr))
For i = lbound(arr) to ubound(arr)
arrTemp(i) = 2 * arr(i)
Next
TimesTwo = arrTemp
End Function
Also can arrays only be declared as variants in situations such as this one.
Thanks,
Wayne C.
|