Click here to Skip to main content
13,259,779 members (56,391 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 24 Sep 2010

Convert Vertical List to String Array

, 24 Sep 2010
Rate this:
Please Sign up or sign in to vote.
This converts a vertical list to a comma-delimited list with each entry enclosed in double quotes.

With a vertical list in a textbox, just select the lines to convert and call the code from a toolstrip button. Conversion is very fast. It ignores blank lines within the list, but will tack on an extra comma if you select a blank line below the last list entry.

Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
  myStr = String.Empty
  Dim arr() As String = txt.SelectedText.Split(Chr(10))
  For l = 0 To arr.Length - 1
    If arr(l).Length > 0 Then
      myStr &= Chr(34) & arr(l) & Chr(34)
      If l < arr.Length - 1 AndAlso arr(l).Length > 0 Then
        myStr &= ","
      End If
    End If
  txt.SelectedText = myStr
End Sub


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...

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 3 A useful operation, but not the most... Pin
CIDev7-Oct-10 4:07
memberCIDev7-Oct-10 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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