0

首先,我还是 VB.net 的新手,我遇到了一个奇怪的问题

我创建了一个工具,它将多行文本框 A 中的内容拆分为字符串行并添加一些字符并将它们连接回来并显示在另一个多行文本框 B 中(A -> 拆分内容 -> 添加字符 -> 加入 -> 在 B 中显示)。样本会是这样的

A的原始数据:

This
is
a
test
data

B中显示的结果:

Row 0 = This
Row 1 = is
Row 2 = a
Row 3 = test
Row 4 = data

从 B 复制的结果:

Row 0 = This
Row 1 = 
is
Row 2 = 
a
Row 3 = 
test
Row 4 = 
data

源代码是

tempA = ""
tempB = ""

tempA = A.Text()
stringAry = tempA.Split(Environment.NewLine)
For iCounter As Integer = 0 To stringAry.Length - 1
tempB = tempB + "Row " + iCounter.ToString + " = " + stringAry(iCounter).ToString +     Environment.NewLine
Next
B.Text() = tempB

那么我可以知道为什么复制的结果与显示的结果不同,我该如何解决这个问题?

4

1 回答 1

0

您应该从值中删除任何不需要的换行符stringAry(iCounter)

tempA = ""
tempB = ""

tempA = A.Text()
stringAry = tempA.Split(Environment.NewLine)
For iCounter As Integer = 0 To stringAry.Length - 1
tempB = tempB + "Row " + iCounter.ToString + " = " + stringAry(iCounter).ToString.Replace(Environment.NewLine, string.Empty) +     Environment.NewLine
Next
B.Text() = tempB
于 2013-07-02T07:02:58.827 回答