Click here to Skip to main content
12,825,861 members (35,706 online)
Click here to Skip to main content
Alternatives (4)
Add your own
alternative version

Tagged as


2 bookmarked
Posted 24 Sep 2010

Convert Vertical List to String Array

, 24 Sep 2010 CPOL


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

24 Sep 2010
Ron Beyer
You may want to take a look at String.Join:Your code can be compressed to:Dim str as Stringstr = Chr(34) + String.Join(Chr(34) + "," + Chr(34), arr) + Chr(34)(My VB skills are a bit lacking, so the syntax may be a bit off, but you get the idea).
27 Sep 2010
Alan Burkhart
I'd never used String.Join before. Didn't even know it was there. :laugh: However, part of the idea is to skip all empty lines AND not end up with an empty string at the end (which my first code didn't address) AND insert the quotes. To get all this done with String.Join, it still took 8...
6 Oct 2010
Prerak Patel
Pretty simple to ignore blank entries..Dim s As String = """" & String.Join(""",""", txt.SelectedTextt.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)) & """"


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alan Burkhart
United States United States
I'm not an IT guy. Programming has been a hobby for me (and occasionally useful) ever since a sister in-law introduced me to a TI-99 4/A about a million years ago.

The creative challenge is relaxing and enjoyable. As such, I'd never mess up a fun hobby by doing it for a living.

Now, if I can just get Code Project to add "Truck Driver" to the list of job titles in the profiles...

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 24 Sep 2010
Article Copyright 2010 by Alan Burkhart
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid