Split a a string based on new line

how to split a astring based on new line
input -
abc
ert
4234
asd

I want to split this and save in 4 separate variables

2 Likes

You can try this code. @Gaurav_Bahuguna

str.Split(CChar(vbCrLf ))

cheers :smiley:

Happy learning :smiley:

1 Like

A note here is that when you split the string you will automatically get a array of the strings which you can simple access using the index 0…3.
Now you can choose to assign then individually to new 4 variables or you can use them using their array index.

not working
this is the data in excel cell


I am using this but not working

1 Like

try:
yourString.Split(Environment.NewLine.TocharArray)

i think the delimited of this is new line right,can you replace the new line with another delimited and from then assign it to array i hope it make sense @Gaurav_Bahuguna

cheers :smiley:

Happy learning :smiley:

1 Like