How to use \n new line in VB msgbox() …?

2020-05-15 14:48发布

What is the alternative to \n (for new line) in a VB.NET MsgBox()?

16条回答
forever°为你锁心
2楼-- · 2020-05-15 15:17
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"

查看更多
劳资没心,怎么记你
3楼-- · 2020-05-15 15:18
  • for VB: vbCrLf or vbNewLine
  • for VB.NET: Environment.NewLine or vbCrLf or Constants.vbCrLf

Info on VB.NET new line: http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

The info for Environment.NewLine came from Cody Gray and J Vermeire

查看更多
淡お忘
4楼-- · 2020-05-15 15:18
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)
查看更多
成全新的幸福
5楼-- · 2020-05-15 15:19

You can use carriage return character (Chr(13)), a linefeed character (Chr(10)) also like

MsgBox "Message Name: " & objSymbol1.Name & Chr(13) & "Value of BIT-1: " & (myMessage1.Data(1)) & Chr(13) & "MessageCount: " & ReceiveMessages.Count
查看更多
Summer. ? 凉城
6楼-- · 2020-05-15 15:20

An alternative to Environment.NewLine is to use :

Regex.Unescape("\n\tHello World\n")

from System.Text.RegularExpressions

This allows you to escape Text without Concatenating strings as you can in C#, C, java

查看更多
ら.Afraid
7楼-- · 2020-05-15 15:21

This work for me: MessageBox.Show("YourString" & vbcrlf & "YourNewLineString")

查看更多
登录 后发表回答