array() function

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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.
 
Back
Top