Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Comments

  • Last UpdatedJul 18, 2023
  • 2 minute read

Comments are non-executed sections of code that are ignored by the VBA compiler. Comments allow programmers to describe the purpose of a section of code to facilitate code maintenance.

As in other BASIC programming languages, both the apostrophe character ( ' ), and the keyword REMare recognized as the start of a comment in VBA. All characters following an apostrophe or the keyword REM are ignored by the VBA compiler until it reaches the end of the line. Line continuation characters do not work inside comments.

REM, like all other keywords and most names in VBA, is not case sensitive.

' This whole line is a comment

rem This whole line is a comment

Rem This whole line is a comment

REM This whole line is a comment

Both types of comments can be used on their own separate line, or the apostrophe character can be used to start a comment at the end of a statement on the same line as a statement.

Pump234.AddPoint( 25, 100 ' Add point to pump 234

Everything placed on the same line after an apostrophe is treated by VBA as a comment. If you want to place a comment on the same line as a statement, the comment must be placed last after all statements on that line. Comments cannot be placed between multiple statements on the same line.

Not every line of code requires a comment. In fact, VBA should contain understandable naming structures and be laid out in such a manner as to make comments unnecessary. However, where a complex function, equation, or logic structure is not readily understandable by viewing the code, it is good practice to include a pertinent comment to make the code more understandable when viewed in isolation.

See Also

VBA Files

TitleResults for “How to create a CRG?”Also Available in