VBA Line Continuation Character
- Last UpdatedJul 18, 2023
- 1 minute read
The underscore is the line continuation character in VBA. There must be a space before and after the line continuation character. Line continuation characters do not work inside comments.
The following sample code statements are treated identically in VBA:
Pump234.AddPoint _( 25, 100)
Pump234.AddPoint( 25, 100)
Strings cannot be separated between lines using the line-break character in VBA, unless the strings are properly enclosed within double quotes on each line, and appended together as per the following example:
Dim strSample as String
strSample = "This sentence on the first line in my code. " _
& "This sentence is on the second line in my code. " _
& "Yet all would display on the same line " _
& "if the display were wide enough."