I\'m trying to convert this code from C# to VB.NET
string[] lines = theText.Split(new string[] { \"\\r\\n\", \"\\n\" }, StringSplitOptions.None);
You can't use backslash (\
) to escape characters in VB. Use the ControlChars
class:
Dim arg() As String = { ControlChars.CrLf, ControlChars.Lf }
From an online converter:
Your c# code:
string[] lines = theText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
Converted to VB.NET:
Dim lines As String() = theText.Split(New String() {vbCr & vbLf, vbLf}, StringSplitOptions.None)
Escape sequences don't really exist in VB .Net as far as string literals are concerned.
There are 2 special constants which you can use instead:
vbCrLf
vbLf
Dim Excluded() As String
Dim arg() As String = {vbCrLf, vbLf}
Excluded = txtExclude.Text.Split(arg, StringSplitOptions.None)
For i As Integer = 0 To Excluded.GetUpperBound(0)
MessageBox.Show("'" & Excluded(i) & "'")
Next
Should do the trick (untested though).