Home All Groups Group Topic Archive Search About

how to devide string to array?

Author
13 Sep 2006 11:53 PM
xuts
hi any body,
how to devide some string like "aaa,bbb,ccc,ddd" to a string array? Is there
have any vb function to do that?

thanks.

Author
14 Sep 2006 12:08 AM
David Hogue
xuts wrote:
> hi any body,
> how to devide some string like "aaa,bbb,ccc,ddd" to a string array? Is there
> have any vb function to do that?

Dim input As String = "aaa,bbb,ccc,ddd"
input.Split(","c)

This will give you an array an array of four strings: "aaa", "bbb",
"ccc", and "ddd"


--
David Hogue
Author
14 Sep 2006 12:10 AM
Greg
"xuts" <x***@discussions.microsoft.com> wrote in message
news:062900A8-0E64-4F91-B19B-D4689573FB8A@microsoft.com...
> hi any body,
> how to devide some string like "aaa,bbb,ccc,ddd" to a string array? Is
> there
> have any vb function to do that?
>
> thanks.

Dim sInput As String = "aaa,bbb,ccc,ddd"
Dim aArray()
sArray = sInput.Split(",")

Now, sArray(0) will contain "aaa", sArray(1) will contain "bbb", etc.

Cheers.
Author
14 Sep 2006 12:11 AM
rowe_newsgroups
Check out the split function

i.e.

        ' This will split the string on the comma character
        Dim str As String = "aaa,bbb,ccc,ddd"
        Dim arr() As String = str.Split(",")

Thanks,

Seth Rowe


xuts wrote:
Show quoteHide quote
> hi any body,
> how to devide some string like "aaa,bbb,ccc,ddd" to a string array? Is there
> have any vb function to do that?
>
> thanks.