Search code examples
vb.netstringsplit

How to split new line in string in vb.net


for example .. If I have a text like this

214asd
df5df8
d66f66

I want to split them into 3 strings using vb.net .


Solution

  • Assuming you want to split on new lines - using String.Split will return an array containing the parts:

    Dim parts As String() = myString.Split(new String() {Environment.NewLine},
                                           StringSplitOptions.None)
    

    This will be platform specific, so you may want to split on "\n", "\r", "\n\r" or a combination of them. String.Split has an overload that takes a string array with the strings you wish to split on.