473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 1306
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: alexk | last post by:
I've a simple question. Why the following: words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./') doesn't work? The length of the result vector is 1. I'm using ActivePython 2.4 Alex
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
3
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim:...
6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns = Line2.Split("\",\"".ToCharArray());
3
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; //...
5
by: KC | last post by:
Can I do a split() on a string where the delimiter is one or more space characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but...
4
by: Michele Petrazzo | last post by:
Hello ng, I don't understand why split (string split) doesn't work with the same method if I can't pass values or if I pass a whitespace value: >>> "".split() >>> "".split(" ") But into...
7
by: Matthias Winterland | last post by:
Hi, I have a simple question. When I read in a string like: a='1,2,3,4,5 6 7,3,4', can I get the list l= with a single split-call? Thx, Matthias
9
by: dtex23 | last post by:
Good afternoon all, Question about list assignment in perl... Given a piece of code that looks kinda like this for parsing some '|' delimited input text lines : ($var1, $var2, $var3) =...
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.