Home All Groups Group Topic Archive Search About

Break up string, Comma Delimited

Author
5 Sep 2006 2:57 PM
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.

Author
5 Sep 2006 3:06 PM
Patrice
See "Split" to create an array or "Replace" to change , to newline...

--
Patrice

"JoeW" <wajo0***@stcloudstate.edu> a écrit dans le message de news:
1157468251.619318.116***@m73g2000cwd.googlegroups.com...
Show quoteHide quote
> 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.
>
Author
5 Sep 2006 3:33 PM
Phill W.
JoeW wrote:

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