Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Returns different Variable type

Status
Not open for further replies.

pghsteelers

Technical User
Apr 21, 2006
121
US
Is is possible to pass a string in a function and have it return an array?

Example, I would like to capture a variable to a string and pass that string to a function which converts the string into an array and passes it back as an array.

The only way I am seeing that as possible, but having trouble doing, is to call the function to convert the string to an array inside of a separate function call that is setup to perform some task on the array. Therefore it will be passed to the final function as an array.

Any suggestions?
Note = I am trying to avoid having to put the string to array part of the code in the body, but actually have it as a separate function. Or maybe there is a way to pass that array back to the body of the script that isn't through the function?
 
Proof of concept:
Function myArray(s)
myArray=Split(s)
End Function
MsgBox UBound(myArray("0 1 2 3 4"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top