Previous Document Next Document

Understanding automation : How is automation coding structured? : Including comments

Including comments

Comments in VBA — similarly to in ANSI, C++, and Java — can be created only at the end of a line. Comments begin with an apostrophe ( ' ) and terminate at the end of the line.

Each line of a multi-line comment must begin with its own apostrophe in VBA:

a = b ' This is a really interesting piece of code that
' requires so much explanation that I needed to break
' the comment over multiple lines.

To comment out large sections of VBA code, use the following syntax (similarly to in C or C++):

#If 0 Then ' That's a zero, not the letter 'oh'.
' All this code will be ignored by
' the compiler at run time!
#End If

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.