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

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


Solution 1:

  • 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

Solution 2:

Try using vbcrlf for a newline

msgbox "This is how" & vbcrlf & "to get a new line"

Solution 3:

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)

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