array() function


G

Guest

I'm trying to stuff a list of string values into individual array elements,
and I'm missing something stupid in the syntax.

Dim tIdents() As Variant, tString as string
Dim i As Integer, j As Integer
tString = "a,b,x"
tIdents = Array(tString) ' or Array(cvar(tString)) ?
j = UBound(tIdents)
For i = 0 To j: Debug.Print i & ": " & tIdents(i): Next i

everything gets stuffed into element 0. What am I missing here?

Thanks,

Kevin
 
Ad

Advertisements

A

Allen Browne

If this is Access 2000 or later, you could use the Split() function to turn
the delimited string into an array.

Function DemoSplit()
Dim aVar() As String
Dim i As Integer
Dim strSource As String

strSource = "abc, ddd, 12q, q8, 66666, dog"
aVar() = Split(strSource, ", ")
For i = 0 To UBound(aVar())
Debug.Print aVar(i)
Next
End Function
 
Ad

Advertisements

G

Guest

Thanks, Allen. That's exactly what I needed. Maybe MS should add Split to
the See Also tab for Array, or just show it as an example right there. The
example they have for Array() is misleading.
 

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

Top