That would have been cool, Scott, except that in their infinite wisdom, the
powers that be omitted a suitable overload that can take just a string as
the delimiter.
A single char works because the String.Split(char()) overload takes a
ParamArray which can be 1 char or many seperate char but if you feed it
String.Split(ChrW(13), Chr(10)) it wouldn't treat the 2 characters as a
combined entity. Instaed it would split on either CR or LF and still give
incorrect results for this case.
The first overload that takes a string, actually takes an Array of strings
(and not a ParamArray) and so the usage actually needs to be, (in this
case):
Dim result As String() = theString.Split(New String()
{Environment.NewLine}, StringSplitOptions.None)
or:
Dim result As String() = theString.Split(New String()
{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
Unfortunately, in my haste to point out your error, I still got it wrong in
my first post to this thread. (Consider my wrist slapped.)
"Scott M." <s-***@nospam.nospamwrote in message
news:ei**************@TK2MSFTNGP02.phx.gbl...
Yes, I see. I had thought that Chr(13) would get the entire CRLF.
But, in your suggestion, the "New String()" is not needed as the Split
method returns an implied string array anyway. So, it seems the best
choice is a combination of our suggestions:
Dim result As String() = theString.Split(Environment.NewLine)
"Stephany Young" <noone@localhostwrote in message
news:OF**************@TK2MSFTNGP03.phx.gbl...
>Well, seeing as how the OP has a string with CRLF's in it and want's to
split it on CRLF, how is:
dim result As String() = theString.Split(Chr(13))
going to do that?.
It is going to split the string on CR and leave the LF character at the
beginning of the 2nd and subsequent elements of the resulting array.
"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>No, I don't.
"Stephany Young" <noone@localhostwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
Don't you mean?:
Dim result As String() = theString.Split(New String()
{Environment.NewLine})
"Scott M." <s-***@nospam.nospamwrote in message
news:Oj**************@TK2MSFTNGP06.phx.gbl...
dim result As String() = theString.Split(Chr(13))
>
>
"sloan" <sl***@ipass.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>>
>String.Split ?
>>
>http://msdn2.microsoft.com/en-us/lib...ing.split.aspx
>>
>"John" <Jo**@nospam.infovis.co.ukwrote in message
>news:OP*************@TK2MSFTNGP06.phx.gbl.. .
>>Hi
>>>
>>I have a multi-line address field which has each line separated by
>>CRLF.
>How
>>can I split this field into individual strings using crlf as
>>separator?
>>>
>>Thanks
>>>
>>Regards
>>>
>>>
>>
>>
>
>