Arrays as Arguments in Functions

D

Dean

I'm having some trouble with this function. I want to
preserve the values of array between calls to a function.
But I cannot figure out how to define the argument for the
function and what the call function statement should look
like. Has anyone done this?
 
S

Stephen Bullen

Hi Dean,
I'm having some trouble with this function. I want to
preserve the values of array between calls to a function.
But I cannot figure out how to define the argument for the
function and what the call function statement should look
like. Has anyone done this?

Something like this (untested):

Sub Test()

Dim asStuff(0 to 1) As String

asStuff(0) = "Hello"
asStuff(1) = "Goodbye"

MsgBox WhatString(asStuff)

End Sub

Function WhatString(ByRef asArray() As String) As String
WhatString = asArray(0) & ", " & asArray(1)
End Function

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie
 
Top