在 VB.net 中的连接字符串之间添加换行符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1411313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 13:18:38  来源:igfitidea点击:

Add a break line between concatenated strings in VB.net

.nettexttextboxconcatenation

提问by TuxMeister

I am trying to concatenate the output of various functions into a textbox, but it all comes up in one biiig line. How can I insert break lines in between the variables? I have something like this:

我试图将各种函数的输出连接到一个文本框中,但它们都出现在一个 biiig 行中。如何在变量之间插入断线?我有这样的事情:

Me.TextBox.text = output1 + output2

And I would like to have something like this:

我想要这样的东西:

Me.TextBox.text = output1 + ENTER + output2

Any ideas?

有任何想法吗?

Thanks!

谢谢!

回答by Noldorin

The Environment.NewLineread-only variable is what you want to use. There's also vbCrLf, but this is for legacy purposes and notenvironment-dependant.

Environment.NewLine只读变量是您要使用的东西。还有vbCrLf,但这是为了遗留目的而不是依赖于环境。

Try the following:

请尝试以下操作:

Me.TextBox.Text = output1 + Environment.NewLine + output2

回答by Pondidum

Me.TextBox.text = output1 & Environment.NewLine & output2

Also use & to concat strings vb.net, + is legacy support

也使用 & 连接字符串 vb.net,+ 是遗留支持

回答by Steve Wortham

Environment.NewLine is usually the preferred method. It'll produce a carriage return & line feed for Windows systems and a line feed only for Unix systems...

Environment.NewLine 通常是首选方法。它将为 Windows 系统生成一个回车和换行符,而只为 Unix 系统生成一个换行符...

http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

Also note that you can use vbCrLf from the Microsoft.VisualBasic namespace which will alwaysreturn a carriage return and line feed together.

另请注意,您可以使用 Microsoft.VisualBasic 命名空间中的 vbCrLf,它将始终一起返回回车符和换行符。