473,698 Members | 2,521 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 4687
"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
7999
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
1427
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
4967
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
1239
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
1055
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
4502
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
6001
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
1553
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
2832
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
8683
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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
9031
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
8876
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...
0
7741
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5867
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
4372
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...
2
2341
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.