What is the alternative to \n (for new line) in a MsgBox()?
How to use \n new line in VB msgbox() ...?
469.1k Views Asked by Wasim A. AtThere are 17 best solutions below
On
These are the character sequences to create a new line:
vbCris the carriage return (return to line beginning),vbLfis the line feed (go to next line)vbCrLfis the carriage return / line feed (similar to pressing Enter)
I prefer vbNewLine as it is system independent (vbCrLf may not be a true new line on some systems)
On
Use the command "vbNewLine"
Example
Hello & vbNewLine & "World"
will show up as Hello on one line and World on another
On
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
On
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
On
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)
On
msgbox("your text here" & Environment.NewLine & "more text") is the easist way. no point in making your code harder or more ocmplicated than you need it to be...
vbCrLforvbNewLineEnvironment.NewLineorvbCrLforConstants.vbCrLfInfo on VB.NET new line: http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx
The info for
Environment.NewLinecame from Cody Gray and J Vermeire