Break up string, Comma Delimited

  • Thread starter Thread starter JoeW
  • Start date Start date
J

JoeW

Just wondering as I'm sure someone's done something similar to this
before, I need to break up a string, broken up everytime a comma is
come across.

In example:
A, B, C, D, E


This can either be broken up into newlines, like

A
B
C
D
E

or into an array.

Any help anyone could offer would be greatly appreciated.
 
JoeW said:
Just wondering as I'm sure someone's done something similar to this
before, I need to break up a string, broken up everytime a comma is
come across.

If you only have to split by the comma's (or you have VB'2005), use
[String].Split.

Dim s1 As String = "A, B, C, D, E"
Dim s2 As String() = s1.Split( ", " )

If you have to split the string by the sequence <comma><space> /and/
you're still using VB'2003, then use Microsoft.VisualBasic.Split(),
which allows for multiple-character delimiters.

Imports VB = Microsoft.VisualBasic

Dim s1 As String = "A, B, C, D, E"
Dim s2 As String() = VB.Split( ", " )

HTH,
Phill W.
 
Back
Top