Loading comma-delimited string into array

R

Ryan

Hello,

I'm passing a form a comma-delimited list of values as a
string. The string lookes like this:

"F101", "F101", "F101"

I'm using Chr(34) to put the actual quotes around the
values.

I would like to load these individual values into an
array. I've tried using the array function like this:

variant = Array(stringOfCommaDelimitedValues)

When I try to reference the variant as an array (as the
Access help file says you can) like this: variant(0) I get
all the values instead of just the first.

Does anyone have a better way of loading a comma-delimited
string into an array.
 
R

Ryan

Dan,

I'm using access 97 and I don't think the split function
is available. I looked at the description of it on MSDN
however. It seems to be exactly what I need. I'll have
to find some other way. Thanks.

Ryan
 
A

Allen Browne

To pass a comma-delimited list of values into a function and have it treated
as an array, declare the function argument as a ParamArray.

If you call the example below like this:
? ShowArray("Cat", "Dog", "Horse")
you get the results:
Cat
Dog
Horse

Function ShowArray(ParamArray MyItems()) As Variant
Dim i As Integer

For i = LBound(MyItems) To UBound(MyItems)
Debug.Print MyItems(i)
Next
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Array to String 9
String with comma delimited values to array 1
Problems using Array() 16
Error on UBound with Dynamic Array 9
importing data 1
Array basics! 3
Multiple Delimiters in Array 5
array() function 2

Top