【发布时间】:2018-07-13 21:16:15
【问题描述】:
我有一个 RichTextBox,用户将在其中输入产品条形码,并将其分隔到新行上。
然后我想获取文本并将其传递给字符串,但用分号替换新行以分隔它们。
Dim products As String = txt_distributorProducts.Text
我可以使用.Replace() 方法并将“\n”替换为“;”吗?或者这行不通。
感谢您的帮助。
【问题讨论】:
-
我的想法是正确的,但是我需要使用 ControlChars.Lf 而不是 "\n"
-
是的,你可以使用它。
-
是的,"\n" 在 VB 中没有特殊含义,因为 VB 不支持将反斜杠作为转义字符。这在 C# 中可以工作。
-
String.Join(";", txt_distributorProducts.Lines)
标签: vb.net richtextbox