472,144 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

String variable with comma delimited list to Array

Jim
Hello:

I have a variable which contains a comma delimited list contained in a
database variable e.g. "5,6,9,10,55,42" - I want to hand this list to
an array function to get it to populate an array, such as follows
(where rst!Q10ACode is the database variable):

Dim ListArray as Variant
Dim Substring1 as String

SubString1 = rst!Q10ACode
ListArray = Array(SubString1)

________________
When I do this, it returns the string length as 14, so I know it's
getting the string, but the UBound of the array is 0, and if I try to
access ListArray(1) and get an index out of bounds error. Can someone
let me know what I'm doing wrong?

Many thanks.

Jim

Aug 21 '07 #1
2 4576
On Tue, 21 Aug 2007 14:02:13 -0000, Jim <ja*************@gmail.com>
wrote:

That's because of the difference between an array and a variant array.
The Array function returns the latter, the Split function the former.
Take your pick (but realize no variant arrays in DotNet).

-Tom.

>Hello:

I have a variable which contains a comma delimited list contained in a
database variable e.g. "5,6,9,10,55,42" - I want to hand this list to
an array function to get it to populate an array, such as follows
(where rst!Q10ACode is the database variable):

Dim ListArray as Variant
Dim Substring1 as String

SubString1 = rst!Q10ACode
ListArray = Array(SubString1)

________________
When I do this, it returns the string length as 14, so I know it's
getting the string, but the UBound of the array is 0, and if I try to
access ListArray(1) and get an index out of bounds error. Can someone
let me know what I'm doing wrong?

Many thanks.

Jim
Aug 21 '07 #2
On Tue, 21 Aug 2007 07:16:00 -0700, Tom van Stiphout
<no*************@cox.netwrote:

I should have added:
To iterate a variant array write:
dim v as variant
for each v in ListArray
...
next v
>On Tue, 21 Aug 2007 14:02:13 -0000, Jim <ja*************@gmail.com>
wrote:

That's because of the difference between an array and a variant array.
The Array function returns the latter, the Split function the former.
Take your pick (but realize no variant arrays in DotNet).

-Tom.

>>Hello:

I have a variable which contains a comma delimited list contained in a
database variable e.g. "5,6,9,10,55,42" - I want to hand this list to
an array function to get it to populate an array, such as follows
(where rst!Q10ACode is the database variable):

Dim ListArray as Variant
Dim Substring1 as String

SubString1 = rst!Q10ACode
ListArray = Array(SubString1)

________________
When I do this, it returns the string length as 14, so I know it's
getting the string, but the UBound of the array is 0, and if I try to
access ListArray(1) and get an index out of bounds error. Can someone
let me know what I'm doing wrong?

Many thanks.

Jim
Aug 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by RH | last post: by
1 post views Thread by John B. Lorenz | last post: by
5 posts views Thread by XML newbie: Urgent pls help! | last post: by
61 posts views Thread by Marty | last post: by
2 posts views Thread by gh | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.