Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 950
Wasim A. Avatar asked Mar 01 '11 08:03

Wasim A.


People also ask

How do I create a new line in a message box in VBA?

If you want to force a new line in a message box, you can include one of the following: The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf. The character codes for a carriage return and line feed, Chr(13) & Chr(10).

How do I break a line in a Messagebox in VBA?

CHR (10) is the code to insert a new line in VBA.

What is vbNewLine in VBA?

vbNewLine inserts a newline character that enters a new line. In the below line of code, you have two strings combined by using it. Range("A1") = "Line1" & vbNewLine & "Line2" When you run this macro, it returns the string in two lines. It returns the character 13 and 10 (Chr(13) + Chr(10)).


2 Answers

  • 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

like image 183
Fun Mun Pieng Avatar answered Sep 19 '22 16:09

Fun Mun Pieng


Try using vbcrlf for a newline

msgbox "This is how" & vbcrlf & "to get a new line" 
like image 36
Developer Avatar answered Sep 18 '22 16:09

Developer