472,378 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 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 1194
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 = " ",...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.