By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

Split text into an array

P: n/a
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.Text

serverarray = userdata.Split(vbCrLf)

Console.WriteLine(serverarray(0))
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.Text

serverarray = userdata.Split(vbCrLf)

Console.WriteLine(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

P: n/a
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*****@nodirecwayspam.com> wrote in message
news:%2****************@tk2msftngp13.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.Text

serverarray = userdata.Split(vbCrLf)

Console.WriteLine(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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.