VB.NET不需要的额外中断

VB.NET不需要的额外中断,vb.net,Vb.net,我有下面的代码 Dim orderlist As List(Of String) = New List(Of String) For i As Integer = 0 To newacctlist.Items.Count - 1 orderlist.Add("This order will be placed on" & newacctlist.Items(i)) Next (i) Textbox1.Lines = orderlist.ToArray 当我从txt文件导入项目时

我有下面的代码

Dim orderlist As List(Of String) = New List(Of String)
For i As Integer = 0 To newacctlist.Items.Count - 1
    orderlist.Add("This order will be placed on" & newacctlist.Items(i))
Next (i)
Textbox1.Lines = orderlist.ToArray
当我从txt文件导入项目时,结果是,第一个项目的结果是正确的,但下一个项目的结果是不必要的中断。结果如下:

This order will be placed on
Monday
而不是

This order will be placed on Monday
从txt文件导入

Dim a As String = My.Computer.FileSystem.ReadAllText(path & "\neworder.txt")
Dim b As String() = a.Split(vbNewLine)
newacctlist.Items.AddRange(b)
如何修复此错误


提前感谢

我能想到的唯一一件事是,您的
新帐户列表
-项目中有一个
换行符
-字符

或derlist.Add()行上放置一个断点,然后检查这些值

还可以查看创建
newacctlist
的代码。 也许你的罪魁祸首就在那里

**编辑**

vbNewLine上的拆分将其包含在字符串中

Dim a As String = My.Computer.FileSystem.ReadAllText(path & "\neworder.txt")
Dim b As String() = a.Split(vbNewLine)
For Each s As String In b
    Console.WriteLine(s.Replace(vbCr, "").Replace(vbLf, ""))
Next

我能想到的唯一一件事是,您的
newacctlist
-项目中有一个
换行符

或derlist.Add()行上放置一个断点,然后检查这些值

还可以查看创建
newacctlist
的代码。 也许你的罪魁祸首就在那里

**编辑**

vbNewLine上的拆分将其包含在字符串中

Dim a As String = My.Computer.FileSystem.ReadAllText(path & "\neworder.txt")
Dim b As String() = a.Split(vbNewLine)
For Each s As String In b
    Console.WriteLine(s.Replace(vbCr, "").Replace(vbLf, ""))
Next
修剪它

orderlist.Add("This order will be placed on" & newacctlist.Items(i).Trim  )
---------------------------------------------------------------------^
修剪它

orderlist.Add("This order will be placed on" & newacctlist.Items(i).Trim  )
---------------------------------------------------------------------^

谢谢,Trim完成了任务,但我也会尝试。谢谢,Trim完成了任务,但我也会尝试