G
Guest
I want to parse a string into three parts. I'm considering three approaches:
1) Global variables with a Sub to fill the values.
2) Three separate functions, each returning one part of the parsed string.
3) A function to return a three-element array.
Of these three approaches, I think 3 is the most compact and easy to follow,
but what is eluding me is how do I get a Function to return an array? It
seems possible but I find no documentation on how to do this, and my approach
is failing. Don't get bogged down in the details of my Function. The key is
that I had hoped to populate the array via ParseMemoNumber(array element
number)= some operation...
What happens in practice is that as soon as the Function gets to the first
assignment, ParseMemoNumber(3) = Trim(Right(strMemoNumber,
Len(strMemoNumber) - LastDashPosition - 3))
it calls the function again i.e. it calls itself recursively. That won't do.
Don't spend a lot of time on this, the Function is easy enough to use the
other two approaches, but my preference is to use a single function. Perhaps
someone has a quick answer as to whether or not this is possible and if it
is, toss a sample over the fence. If its possible, this SHOULD be a
cakewalk, but it eludes me at the moment.
FYI: The Function should accept a string in the form of
String1-String2-String3.
Thanks
1) Global variables with a Sub to fill the values.
2) Three separate functions, each returning one part of the parsed string.
3) A function to return a three-element array.
Of these three approaches, I think 3 is the most compact and easy to follow,
but what is eluding me is how do I get a Function to return an array? It
seems possible but I find no documentation on how to do this, and my approach
is failing. Don't get bogged down in the details of my Function. The key is
that I had hoped to populate the array via ParseMemoNumber(array element
number)= some operation...
What happens in practice is that as soon as the Function gets to the first
assignment, ParseMemoNumber(3) = Trim(Right(strMemoNumber,
Len(strMemoNumber) - LastDashPosition - 3))
it calls the function again i.e. it calls itself recursively. That won't do.
Don't spend a lot of time on this, the Function is easy enough to use the
other two approaches, but my preference is to use a single function. Perhaps
someone has a quick answer as to whether or not this is possible and if it
is, toss a sample over the fence. If its possible, this SHOULD be a
cakewalk, but it eludes me at the moment.
FYI: The Function should accept a string in the form of
String1-String2-String3.
Thanks