Add newline to VBA or Visual Basic 6

Gerhard Powell picture Gerhard Powell · Nov 21, 2014 · Viewed 149k times · Source

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?

Answer

Gerhard Powell picture Gerhard Powell · Nov 21, 2014

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