Unable to split a string with newLine delimiter?

I made a string variable

a =“this is
new line”

but not able to get split it using new line.
I have tried
a.Split(VbCrLf, StringSplitOptions.NONE)

not returning two elements indeed returning full string. why ??

have you tested changing vbCrLf with Environment.NewLine?


Try these expressions:

a.split(Environment.NewLine.TocharArray)(0) - this is

a.split(Environment.NewLine.TocharArray)(1) - new line

Okay. I’ll tell u what I’ve used?

Now not able to get the required result.

@blacksundar try vbNewLine

Sorry I missed that, I have also used that :wink:

@blacksundar are you splitting using .ToCharArray? Split(vbNewLine.ToCharArray) . Because this is working for me

Hi @blacksundar

try this


1 Like

Hi @blacksundar,

Please try the below syntax and try once.

a.Split(VBNewline.tocharArray, StringSplitOptions.RemoveEmptyEntries)

Shiva Karthik

Thank you all. But I’ll post what didn’t work.

can you all please tell me reasons of all?
a.Split(VBNewline.tocharArray, StringSplitOptions.RemoveEmptyEntries)

what’s difference between
a.Split({vbNewline}, StringSplitOptions.RemoveEmptyEntries)
a.Split(vbNewline.ToCharArray, StringSplitOptions.RemoveEmptyEntries)

1 Like


Could you please share your Workflow. Will check and update you.

Hi @blacksundar

vbCrLf - when you have both carriage return(Cr) and Line feed(Lf) in the string
vbCr - Only when Carriage return(Cr) in the string
vbLf - Only when Line feed(Lf) in the string

a.Split({vbNewline}, StringSplitOptions.RemoveEmptyEntries)
a.Split(vbNewline.ToCharArray, StringSplitOptions.RemoveEmptyEntries)

both function perform same…

after split(u have to use char )

first one assign as char array method {vbNewline}
next one they convert as char array vbNewline.ToCharArray)

so Respected of function u have to mention within the {} otherwise u have to convert as TocharArray()


Hi @amaresan

Thank you so much for your time.
I have tested all methods given in this message.

{}, without{} performed different way. 1st one didn’t split using new line, but second one did…

why is it so?


Split function separates Strings. It receives a string or character delimiter. It parses and separates the source string by separating the parts that come between the delimiter.


could you share me the code which is not working… i will explain why not working


it’s output is “1”

it’s output is “2”


I’m not sure may it perform like this. You u are give two method is single {} that will consider always one

if u use two Cr and Lf in curly braces u have to give like this samplestring.split({vbCr,VbLf},StringSplitOptions.RemoveEmptyEntries).Length.ToString

otherwise use tocharArray()

i hope it make clear