2013-11-04 59 views
0

我有下面的代码;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文件,作为结果,第一个我出来是正确的,但未来的人得到一个不需要休息。他们出来的:从txt文件

This order will be placed on 
Monday 

,而不是

This order will be placed on Monday 

进口

Dim a As String = My.Computer.FileSystem.ReadAllText(path & "\neworder.txt") 
Dim b As String() = a.Split(vbNewLine) 
newacctlist.Items.AddRange(b) 

如何解决这个问题?

在此先感谢

回答

3

修剪它,

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

它的工作!我很感激帮助 –

1

我能想到的唯一的事情是,你必须在你的newacctlist -items一个newline字符数限制。

orederlist.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 
+0

谢谢,修剪做的工作,但我会尝试这个问题,以及 –