What is the alternative to \n
(for new line) in a MsgBox()
?
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).
CHR (10) is the code to insert a new line 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)).
vbCrLf
or vbNewLine
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
Try using vbcrlf
for a newline
msgbox "This is how" & vbcrlf & "to get a new line"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With