Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Convert Vertical List to String Array

, 27 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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...
I'd never used String.Join before. Didn't even know it was there. Laugh | :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 lines instead of 10 in the original. There should be a way to get it done with only a couple lines of code, I'm thinking.
 

Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
  myStr = Chr(34) & String.Join(Chr(34) & "," & Chr(34), txt.SelectedText.Split(Chr(10)))
  myStr = myStr.Replace("," & Chr(34) & Chr(34), String.Empty)
  If myStr.EndsWith("," & Chr(34)) Then
    myStr = myStr.Substring(0, myStr.Length - 2)
  ElseIf Not myStr.EndsWith(Chr(34)) Then
    myStr &= Chr(34)
  End If
  txt.SelectedText = myStr
 
End Sub

License

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

Share

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

Comments and Discussions

 
GeneralYou say that this isn't any less problematic, but I think yo... PinmemberSilic0re091-Oct-10 5:56 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 27 Sep 2010
Article Copyright 2010 by Alan Burkhart
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid