By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

split question

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
* "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

P: n/a
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.