Add newline to VBA or Visual Basic 6

52

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?

This question is tagged with vba vb6

~ Asked on 2014-11-21 17:49:33

The Best Answer is


90

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

~ Answered on 2014-11-21 17:54:15


21

Use this code between two words:

& vbCrLf &

Using this, the next word displays on the next line.

~ Answered on 2016-01-10 04:22:01


Most Viewed Questions: