I want to concatenate two strings with a linebreak between them.
st = "Line 1" + newline + "Line2"
How do I add a newline to VBA or Visual Basic 6?
Example #2 – Insert New Line Using “Char (10)” To a new line instead of “vbNewLine,” we can also use the function CHR to insert a new line in VBA. read more. For example, CHR (10) is the code to insert a new line in VBA.
For it to appear on separate lines within a text file you will need Chr(13) & Chr(10) or vbCrLf or if you're in excel vba vbNewLine . All of which will provide the needed carriage return Chr(13) and line feed Chr(10) characters to produce a line break.
Visual Basic has built-in constants for newlines:
vbCr
= Chr$(13) = CR (carriage-return character) - used by Mac OS and Apple II family
vbLf
= Chr$(10) = LF (line-feed character) - used by Linux and Mac OS X
vbCrLf
= Chr$(13) & Chr$(10) = CRLF (carriage-return followed by line-feed) - used by Windows
vbNewLine
= the same as vbCrLf
Use this code between two words:
& vbCrLf &
Using this, the next word displays on the next 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