vbavb6

Add newline to VBA or Visual Basic 6


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?


Solution

  • 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