473,748 Members | 9,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4690
"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********@rog ers.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********@rog ers.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********@rog ers.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******** ******@TK2MSFTN GP09.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********@rog ers.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
8005
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 = document.forms; // more code here........ }
5
1429
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 from a query string action=edit, now when i click on the update button it does the update event, the problem is, it still has the old unedited data in memory... and places the old stuff back into the database (saw this when debugging) the SQL is...
1
4970
by: thangchan | last post by:
Hi all, i am getting SQL update problem. as below ======================error messages ======================= Server Error in '/CMS' Application. -------------------------------------------------------------------------------- 無值提供給一或多個必要參數。 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
0
1242
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 in one data grid column. Dim file As String = "test.txt" Dim path As String = "C:\" Dim ds As New DataSet("Textfiles")
1
1058
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 language="VB" Debug="false" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %>
4
4507
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 not getting the full data. Is there any max limit for an variable to store in javascript? Can anyone please help me to solve this prob?
3
6005
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 values, transfer those numeric values over ASP.NET. I had no problem doing this on my local computer, by getting the field with "cast(field as BINARY)" so that on ASP.NET I have a byte array.Then send every field of array over ASP.Net.
0
1557
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 databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
0
2005
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 ((string)(this.GetPropertyValue("Address1")));
2
2834
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 timeout period elapsed prior to completion of the operation or the server is not responding." error. The data is being filled from a Stored Procedure on an SQL Server. When I run the Stored Procedure on the actual server, it is only taking 24...
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.