473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 4688
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: RH | last post by:
<SELECT name="txtServices" size="3" multiple> <OPTION value="Massage">Massage</OPTION> <OPTION value="Facials">Facials</OPTION> <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body...
4
by: Christine Forber | last post by:
I wonder if anyone knows of some javascript code to check a comma-delimited list of email addresses for basic formating. What I'm looking for is the javascript code to check a form field on form...
1
by: John B. Lorenz | last post by:
I'm attempting to write an input routine that reads from a comma delimited file. I need to read in one record at a time, assign each field to a field array and then continue with my normal...
14
by: Bob | last post by:
I have a function that takes in a list of IDs (hundreds) as input parameter and needs to pass the data to another step as a comma delimited string. The source can easily create this list of IDs in...
6
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a string, and then from a string back to a byte array. for example Private mByte() as New Byte(4){11,22,33,44} Now how...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
5
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
61
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch...
2
by: gh | last post by:
Hi, I have a string variable which contains n number of comma delimited elements and I would like to store each element into an array but I could not figure how to do it. for example,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.