473,856 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split text into an array

I have a multine list that I would like to split into an array. I paste it
into a richtext box and go from there, but it just makes the first part of
the array the whole list with little boxes inbetween. Here is the code

Dim userdata As String

Dim serverarray As String()

Dim servercount As Integer

userdata = RichTextBox1.Te xt

serverarray = userdata.Split( vbCrLf)

Console.WriteLi ne(serverarray( 0))
Nov 21 '05 #1
3 2521
Microsoft wrote:
I have a multine list that I would like to split into an array. I paste it
into a richtext box and go from there, but it just makes the first part of
the array the whole list with little boxes inbetween. Here is the code

Dim userdata As String

Dim serverarray As String()

Dim servercount As Integer

userdata = RichTextBox1.Te xt

serverarray = userdata.Split( vbCrLf)

Console.WriteLi ne(serverarray( 0))

The delimeter for your lines might NOT be both a vbCr (carriage return)
and a vbLf (line feed); it could also be one or the other.

I would venture a guess that your line is delimited by vbLf's...try
splitting on that instead and see if you get the desired results.

HTH...
Chris
Nov 21 '05 #2
That was exactly the issue .. Thank you!

Is there any way to easily tell what delimiter is being used in the future?

THe code works great when the user pastes from a text editor, but when they
paste from Exel, each entry seems to have a tab after it. Any easy way to
make sure that the data is text and convert it if its not. I am not have
any luick with idata..
"Chris Hyde" <ch*****@nodire cwayspam.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Microsoft wrote:
I have a multine list that I would like to split into an array. I paste it into a richtext box and go from there, but it just makes the first part of the array the whole list with little boxes inbetween. Here is the code

Dim userdata As String

Dim serverarray As String()

Dim servercount As Integer

userdata = RichTextBox1.Te xt

serverarray = userdata.Split( vbCrLf)

Console.WriteLi ne(serverarray( 0))

The delimeter for your lines might NOT be both a vbCr (carriage return)
and a vbLf (line feed); it could also be one or the other.

I would venture a guess that your line is delimited by vbLf's...try
splitting on that instead and see if you get the desired results.

HTH...
Chris

Nov 21 '05 #3
Hello...

http://www.ftponline.com/vsm/2004_11...ns/net2themax/
article titled: Parse Text Files With Regular Expressions

Marc Cramer

Nov 21 '05 #4

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

Similar topics

4
3614
by: Brian Glen Palicia | last post by:
My goal is to accept input from the user into a text box and then parse the data using split(). The first step is this tiny program to test the split() function. It runs in IE, but in Mozilla it just hangs and keeps loading forever. I checked around on the web and in USENET, but I haven't seen any mention of split() not working in Mozilla. Thoughts? Thanks in advance. <HTML> <HEAD> </HEAD>
1
2910
by: jhcorey | last post by:
I don't know where the actual issue is, but hopefully someone can explain. The following displays "5" in FireFox, but "3" in IE: <script type="text/javascript" language="javascript"> var newString = ",a,b,c,"; var treeArray = newString.split(/\,/i); alert(treeArray.length);
1
1702
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our naming standard (unique id) and create them designated folder. This requirement should be created as a batch job and preferrably this job should monitor the folder where one big chunk of text file lands and process them immediately. ...
3
3238
by: Jan Hanssen | last post by:
Hi! I have a list of data in a textfile which is tab delimited. Each line is seperated by a VbCrLf. I want to collect this data in a multidimensional string array. I do not wish to use a database or a Disconnected ADO Recordset since this is just passing data along to be written into an XML file... I've figured out how to split the data line by line by doing a
4
1328
by: Craig Buchanan | last post by:
I am trying to split a comma-delimited string into a string array. unfortunately, if the string doesn't contain a comma, the resulting array is Nothing. other than using vb6 compatibility, is there another option? thanks, Craig Buchanan
3
9672
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3... field1...field2...field3...
6
2177
by: Saurabh | last post by:
Hi everyone, I am looking for some expert advise to get me out of trouble. I am looking for a solution in C# which will allow me to split the below string in the format provided. The String.Split() allows only a single char as a delimiter.So I cannot use that as well. Original String "*** MASTER (Supervisor) *** September 23, 1997 at 3:22pm \r\nThis is the first line of text. There will be many more beneath this on so look...
3
6393
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. The name of file is E:\delibere test\pdf\2002\2002-01-01-GC-000-Testo.pdf <HTML> <HEAD> <SCRIPT LANGUAGE=JAVASCRIPT>
12
3206
by: garyusenet | last post by:
string lines = File.ReadAllLines(@"c:\text\history.txt"); foreach (string s in lines) { ArrayList results = new ArrayList(); string delimit = ";"; string currentline = s.Split(";"); MessageBox.Show(s);
2
1341
by: sicario | last post by:
Hi, givens lines of text such as: the cat sat on the mat the <var> sat on the mat the <var> sat on the <my object> the <var> sat on the <my object> and <action taken by cat> I want to be able to return all instances of my variables (anything within <>). Sometimes the variable will be one word only (i.e <var>, but it may be several (i.e <action taken by cat>)
0
9918
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
9763
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,...
1
10786
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9532
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...
1
7932
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
7097
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
5959
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4175
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.