469,602 Members | 1,979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

split question

I am trying to split a comma-delimited string into a string array.
unfortunately, if the string doesn't contain a comma, the resulting array is
Nothing. other than using vb6 compatibility, is there another option?

thanks,

Craig Buchanan
Nov 20 '05 #1
4 1111
maybe check for the indexof the comma on the string first if there is no
index returned then dont split it to get teh string back, but if there is an
index returned then use the split method
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I am trying to split a comma-delimited string into a string array.
unfortunately, if the string doesn't contain a comma, the resulting array is Nothing. other than using vb6 compatibility, is there another option?

thanks,

Craig Buchanan

Nov 20 '05 #2
Are you certain? In these types of cases it really helps if you post a few
lines of code that demonstrates what you are doing.

Tom

"Craig Buchanan" <so*****@somewhere.com> wrote...
I am trying to split a comma-delimited string into a string array.
unfortunately, if the string doesn't contain a comma, the resulting array is Nothing. other than using vb6 compatibility, is there another option?

thanks,

Craig Buchanan

Nov 20 '05 #3
* "Craig Buchanan" <so*****@somewhere.com> scripsit:
I am trying to split a comma-delimited string into a string array.
unfortunately, if the string doesn't contain a comma, the resulting array is
Nothing. other than using vb6 compatibility, is there another option?


Post your code.

Do you use 'Strings.Split' or the string's 'Split' method for splitting?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #4
Craig,
You should have a single element array returned, with the string in the
first element!

Dim s As String = "this is a test"
Dim values() As String = s.Split(","c)

Debug.WriteLine(values(0))

Remember there are three Split functions in .NET:

Use Microsoft.VisualBasic.Strings.Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Use System.Text.RegularExpressions.RegEx.Split to split based
on matching patterns.

Can you post code?

Hope this helps
Jay

"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I am trying to split a comma-delimited string into a string array.
unfortunately, if the string doesn't contain a comma, the resulting array is Nothing. other than using vb6 compatibility, is there another option?

thanks,

Craig Buchanan

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by alexk | last post: by
2 posts views Thread by SL_McManus | last post: by
3 posts views Thread by rxl124 | last post: by
6 posts views Thread by Senthil | last post: by
3 posts views Thread by John Salerno | last post: by
5 posts views Thread by KC | last post: by
4 posts views Thread by Michele Petrazzo | last post: by
7 posts views Thread by Matthias Winterland | last post: by
1 post views Thread by John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.