Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
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).
Check this out: Dim z = String.Join(",", txt.SelectedText.Split(Chr(10)))
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...
Pretty simple to ignore blank entries..Dim s As String = """" & String.Join(""",""", txt.SelectedTextt.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)) & """"
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...