473,396 Members | 1,738 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,396 software developers and data experts.

split a string into an arraylist?

If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String' cannot
be converted to 'System.Collections.ArrayList'.

How can I split a string into an arraylist?

Thanks

Feb 15 '06 #1
2 34139
"Mad Scientist Jr" <us*************@yahoo.com> schrieb
If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String'
cannot be converted to 'System.Collections.ArrayList'.

How can I split a string into an arraylist?


arrlist.addrange(Split("a,b,c", ","))

Armin

Feb 15 '06 #2
"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
If I try splitting a string into an arraylist

Dim arrList As New ArrayList
arrList = Split("a,b,c", ",")

I get this error: Value of type '1-dimensional array of String' cannot
be converted to 'System.Collections.ArrayList'.


Aren't Constructors Wonderful things?

Creating a new ArrayList /based on/ a String array:

Dim arrList As New ArrayList( "a,b,c".Split( ","c ) )

or, to split by a multiple-character delimiter:

Imports VB=Microsoft.VisualBasic

Dim arrList As New ArrayList( VB.Split( "a<>b<>c", "<>" ) )

HTH,
Phill W.
Feb 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
11
by: | last post by:
Hello everyone! :-D OK, I've came across many functions for this, but none works! I need one that works like this: StringSplit(string str, string delim, vector<string> results) Either with...
9
by: Java and Swing | last post by:
Say I have a string which contains numbers separated by a comma... such as "0,1,2,3,4,5"...I want to split the string at the commas and return an array containing, 0,1...5. Suggestions? I've...
3
by: edoardo.poeta | last post by:
I'm a dummy. I have a basic knowledge of javascript and I want to split a string, but I receive an error at line 15. Where my error in make the array? Why? Can someone help me to resolve? Thank's....
3
by: alfredo17 | last post by:
Some can help me to extract String by String from ArrayList. I can add an String but now I would like to read item by item from an ArrayList. Thanks
7
by: Johny | last post by:
I have a string of a variable length and I need to split the string in strings of 6 characters . But if the 6th character is not space then I must split the string at possition before the 6th...
5
by: shaiful | last post by:
Hi all I have a simple problem with string. I want to split string, such as: dim s as string dim k(3) as string s="aa1,bv1,cc1,dt1" i want to split the value in k, k(0)=aa1 k(1)=bv1...
1
by: Garima12 | last post by:
Hi, There is a string like: parcel = 1 AND id = 546 OR shape = 'point' I want to split this string with AND and OR I wrote split function like: var contentarr = qString2.split("AND"); it...
4
by: dmitrey | last post by:
hi all, howto split string with both comma and semicolon delimiters? i.e. (for example) get from string "a,b;c" I have tried s.split(',;') but it don't work Thx, D.
4
by: N9 | last post by:
Hi Anyone who can help about split string. string text = "History about a boy, who loves to play baseball with his friends." I like to find indexOf "play" and read the string 10 char left...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.