How to split new line in string in vb.net

Dim strLines() As String = Clipboard.GetText.Replace(Chr(13), "").Split(Chr(10))

I like doing it this way. One can only split on a char but in most cases NewLine is two characters, Carriage Return (0x0D AKA Char 13) and Line Feed (0x0A AKA Char 10). But in other systems it's just a LF. So I simply remove all instances of the CR and split on the LF.


str.Split(New String() {Environment.NewLine}, 
          StringSplitOptions.RemoveEmptyEntries)

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.