Click here to Skip to main content
11,496,146 members (1,783 online)
Click here to Skip to main content

Tagged as

Convert Vertical List to String Array

, 6 Oct 2010 CPOL 2.2K 1
Pretty simple to ignore blank entries..Dim s As String = """" & String.Join(""",""", txt.SelectedTextt.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)) & """"
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.

Alternatives

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).
24 Sep 2010
Alan Burkhart
4 alternatives  
24 Sep 2010
jlabrou
Check this out: Dim z = String.Join(",", txt.SelectedText.Split(Chr(10)))
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...

License

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

Share

About the Author

Prerak Patel
Software Developer
India India
Working since 2006 on VBA, VB6, VB.Net, C#, ASP.Net, MSSQL



  • The fear of suffering is worse than the suffering itself.
  • People need not fear the unknown if they are capable of achieving what they need and want.
  • Every blessing ignored becomes a curse.
  • Sometimes what's in your head isn't as crazy as you think.
  • We never really grow up, we only learn how to act in public.
  • You can make very bad teams with very good individuals.
  • Admitting mistakes means you have a sense of responsibility in your actions and that shows you are more matured than almost anyone. -Nithin


| | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 6 Oct 2010
Article Copyright 2010 by Prerak Patel
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid