Split text into an array

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

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))
 
Microsoft said:
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
 
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..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top