473,386 Members | 2,050 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,386 software developers and data experts.

Getting data from string

J
I have a string with lots of numbers i need in a seperate
an array. each number is split using a ",". How do i
split them up and put them in to an array.

eg.
egstring = 1,23,423,2,2

i need to get the numbers
1
23
423
2
2
and then add them to an array.

thanks for any help in advance. J
Nov 20 '05 #1
5 4672
"J" <no@spam> wrote in news:0c****************************@phx.gbl:
I have a string with lots of numbers i need in a seperate
an array. each number is split using a ",". How do i
split them up and put them in to an array.

eg.
egstring = 1,23,423,2,2

i need to get the numbers
1
23
423
2
2
and then add them to an array.


Dim arrInteger as Integer()

arrInteger = Split(egString,",")

That should do it.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2
Hello,

"J" <no@spam> schrieb:
I have a string with lots of numbers i need in a seperate
an array. each number is split using a ",". How do i
split them up and put them in to an array.

eg.
egstring = 1,23,423,2,2

i need to get the numbers
1
23
423
2
2
and then add them to an array.


\\\
Dim s As String = "1,23,423,2,2"
Dim astr() As String = s.Split(","c)
///

- or -

\\\
Dim s As String = "1,23,423,2,2"
Dim astr() As String = Strings.Split(s, ",")
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3
I believe Split() returns a string array so your code would generate an
invalid type exception. If you need it in an integer array, you'll have to
put it in a string array temporarily and loop through the array and stuff it
into a new integer array. Or you can leave it in the string array and
perform any conversions on the fly.
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"J" <no@spam> wrote in news:0c****************************@phx.gbl:
I have a string with lots of numbers i need in a seperate
an array. each number is split using a ",". How do i
split them up and put them in to an array.

eg.
egstring = 1,23,423,2,2

i need to get the numbers
1
23
423
2
2
and then add them to an array.


Dim arrInteger as Integer()

arrInteger = Split(egString,",")

That should do it.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 20 '05 #4
"Jeff Molby" <JeffMolby@C_mc_st.n_t> wrote in
news:Oe**************@TK2MSFTNGP09.phx.gbl:
I believe Split() returns a string array so your code would generate
an invalid type exception. If you need it in an integer array, you'll
have to put it in a string array temporarily and loop through the
array and stuff it into a new integer array. Or you can leave it in
the string array and perform any conversions on the fly.

Oops, you're correct!
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #5
J
thanks for all your help :o)
Nov 20 '05 #6

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

Similar topics

18
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm =...
5
by: Brian Henry | last post by:
I have a page which reads an article from the database it has 1 text box, 2 dropdown lists, and a longreat HTML text box. I load the information from the database when the page is set to edit mode...
1
by: thangchan | last post by:
Hi all, i am getting SQL update problem. as below ======================error messages ======================= Server Error in '/CMS' Application....
0
by: sags | last post by:
Hi , Iam a new uesr of this group. I have a small doubt . Iam using the code mentioned below to retrive the data from tab delimited text file ., but Iam getting all the columns of the text file...
1
by: momo | last post by:
Can some take a look at this and tell me what I am doing wrong and how to fix it. I an new to ASP.NET Getting Name "GetMsAccessOldebConnection' is not declared " Error <%@ Page...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
3
by: ist | last post by:
Hi, I am trying to get (and transfer over ASP.NET) some encrypted data from some MySQL fields. Since the data contains many unicode characters, I tried to get the data as a series of ASCII...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
2
by: Andrew Cooper | last post by:
Greetings, I've got a website that has several pages with DataGrid controls on them. The controls are bound to Object Datasources. On one of the pages I keep getting a "Timeout expired. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: 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
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
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,...

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.