Add a break line between concatenated strings in VB.net

…衆ロ難τιáo~ 提交于 2019-12-10 14:29:05

问题


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:

Me.TextBox.text = output1 + output2

And I would like to have something like this:

Me.TextBox.text = output1 + ENTER + output2

Any ideas?

Thanks!


回答1:


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

Try the following:

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



回答2:


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

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




回答3:


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...

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 always return a carriage return and line feed together.



来源:https://stackoverflow.com/questions/1411313/add-a-break-line-between-concatenated-strings-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!