vb.net 如何在 VB msgbox() 中使用 \n 换行...?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5152042/
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
How to use \n new line in VB msgbox() ...?
提问by Wasim A.
回答by Fun Mun Pieng
- for VB:
vbCrLf
orvbNewLine
- for VB.NET:
Environment.NewLine
orvbCrLf
orConstants.vbCrLf
- 对于 VB:
vbCrLf
或vbNewLine
- 对于VB.NET:
Environment.NewLine
或vbCrLf
或Constants.vbCrLf
Info on VB.NET new line: http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx
关于 VB.NET 新行的信息:http: //msdn.microsoft.com/en-us/library/system.environment.newline.aspx
The info for Environment.NewLine
came from Cody Grayand J Vermeire
信息Environment.NewLine
来自Cody Gray和J Vermeire
回答by Pranay Rana
These are the character sequences to create a new line:
这些是用于创建新行的字符序列:
vbCr
is the carriage return (return to line beginning),vbLf
is the line feed (go to next line)vbCrLf
is the carriage return / line feed (similar to pressing Enter)
vbCr
是回车(回到行首),vbLf
是换行符(转到下一行)vbCrLf
是回车/换行(类似于按回车)
I prefer vbNewLine
as it is system independent(vbCrLf
may not be a true new line on some systems)
我喜欢vbNewLine
,因为它是独立于系统的(vbCrLf
可能不是在某些系统上一个真正的新行)
回答by Developer
Try using vbcrlf
for a newline
尝试使用vbcrlf
换行符
msgbox "This is how" & vbcrlf & "to get a new line"
回答by Jens
回答by Hans Olsson
Add a vbNewLine
as:
添加一个vbNewLine
:
"text1" & vbNewLine & "text2"
回答by slagou
An alternative to Environment.NewLine is to use :
Environment.NewLine 的替代方法是使用:
Regex.Unescape("\n\tHello World\n")
from System.Text.RegularExpressions
来自 System.Text.RegularExpressions
This allows you to escape Text without Concatenating strings as you can in C#, C, java
这允许您在不连接字符串的情况下转义文本,就像在 C#、C、java 中一样
回答by user6225788
The correct format is :
正确的格式是:
"text1" + vbNewLine + "text2"
回答by SQAHero
Use the command "vbNewLine"
使用命令“vbNewLine”
Example
例子
Hello & vbNewLine & "World"
will show up as Hello on one line and World on another
将在一行中显示为 Hello,在另一行中显示为 World
回答by Martin Reicher
msgbox "This is the first line" & vbcrlf & "and this is the second line"
or in .NET msgbox "This is the first line" & Environment.NewLine & "and this is the second line"
或在 .NET 中 msgbox "This is the first line" & Environment.NewLine & "and this is the second line"
回答by user2885689
Module MyHelpers
<Extension()>
Public Function UnEscape(ByVal aString As String) As String
Return Regex.Unescape(aString)
End Function
End Module
Usage:
用法:
console.writeline("Ciao!\n".unEscape)