How to use \ n newline in VB msgbox () ...?

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

+42
newline msgbox
Mar 01 '11 at 8:32
source share
14 answers
  • for VB: vbCrLf or vbNewLine
  • for VB.NET: Environment.NewLine or vbCrLf or Constants.vbCrLf

VB.NET Newline Information: http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

Information for Environment.NewLine taken from Cody Gray and J Vermeire

+56
Mar 01 2018-11-11T00:
source share

These are the sequences of characters to create a new line:

  • vbCr - carriage return (return to the beginning of the line),

  • vbLf is a line (go to the next line)

  • vbCrLf is a carriage return / line return (similar to pressing Enter)

I prefer vbNewLine as it is system independent ( vbCrLf may not be a new new line on some systems)

+19
Mar 01 2018-11-11T00:
source share

Use the Environment.NewLine property

+12
Mar 01 2018-11-11T00:
source share

Try using vbcrlf for a new line

 msgbox "This is how" & vbcrlf & "to get a new line" 
+12
Mar 01 2018-11-11T00:
source share

Add vbNewLine as:

 "text1" & vbNewLine & "text2" 
+5
Mar 01 2018-11-11T00:
source share

An alternative to Environment.NewLine is to use:

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

from System.Text.RegularExpressions

This avoids text without cascading strings, as you can in C #, C, java

+4
Jan 22 '13 at 21:05
source share

Use the "vbNewLine" command

Example

 Hello & vbNewLine & "World" 

appears as Hello on one line and World on another

+2
Apr 17 '12 at 5:18
source share

The correct format is:

 "text1" + vbNewLine + "text2" 
+2
Apr 19 '16 at 15:37
source share
 Module MyHelpers <Extension()> Public Function UnEscape(ByVal aString As String) As String Return Regex.Unescape(aString) End Function End Module 

Using:

 console.writeline("Ciao!\n".unEscape) 
+1
Aug 22 '14 at 15:26
source share

On my side, I created a MyMsgBox submenu replacing \ n at the ControlChars.NewLine prompt

+1
Jul 07 '15 at 13:33
source share

The message field must end with text, not a variable

0
Mar 31 '13 at 12:52
source share

You can use the carriage return character (Chr (13)), the line feed character (Chr (10)) also like

 MsgBox "Message Name: " & objSymbol1.Name & Chr(13) & "Value of BIT-1: " & (myMessage1.Data(1)) & Chr(13) & "MessageCount: " & ReceiveMessages.Count 
0
Mar 20 '14 at 18:26
source share

A lot of the things above didn't work for me. What ultimately works

 Chr(13) 
0
Mar 11 '17 at 18:55
source share

msgbox ("your text is here" and "Environment.NewLine" and "more text") is an easy way. it makes no sense to make your code more complex or more generalized than you need ...

-one
Nov 18 '14 at 16:45
source share



All Articles