我正试图把这段代码从c转换成vb.net

string[] lines = theText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

这里是我的,问题是它在消息框中打印整个文本框内容,而不是每一行。
    Dim Excluded() As String

    Dim arg() As String = {"\r\n", "\n"}

    Excluded = txtExclude.Text.Split(arg, StringSplitOptions.None)

    For i As Integer = 0 To Excluded.GetUpperBound(0)
        MessageBox.Show("'" & Excluded(i) & "'")
    Next

最佳答案

就字符串字符串而言,在VB.NET中确实不存在转义序列。
有两个特殊常数可供使用:
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

应该做的把戏(尽管还没有测试)。

08-07 09:58