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

Splitting a line by comma in VB

P: 1
Hi, i'm a very new user to visual basic and i am looking to split a line like: Isaac, 1.2, 1.8, 1.9, 1.5, 1.6, 1.7, into multiple lines. So far i have:
but this doesn't split into into new lines and when i attempt to use & vbnewline it still won't work. I'd really appreciate any help if you have it.
Jan 20 '15 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,731
The String.Split method returns an array of strings.

You need to loop through the array and add each component to a new string and insert newlines in between each component.

Or better yet use a StringBuilder(<--see this for documentation and examples)

Or you could try using the String.Replace method to replace all of the commas with Environment.Newline (however I'm not 100% sure this will work).

Jan 20 '15 #2

P: 296
Expand|Select|Wrap|Line Numbers
  1. Dim Lines() as String
  2. Lines = myString.Split(",")
  3. For Each Line as String in Lines
  4.    'do something with each line
  5. Next
Jan 30 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.