O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Rem Statement

Syntax

Rem comment
' comment
comment

Use: Optional

A textual comment to place within the code.

Description

Use the Rem statement or an apostrophe (') to place remarks within the code.

Rules at a Glance

Apostrophes held within quotation marks aren’t treated as comment markers, as this code snippet shows:

myVar = "'Something'"

VBA/VBScript Differences

  • In VBA, if you use the Rem statement (but not the apostrophe) on the same line as program code, a colon is required after the program code and before the Rem statement. For example:

    Set objDoc = Server.CreateObject("MyApp.MyObj") : Rem Define the object
                                                      Rem reference

    VBScript, on the other hand, successfully recognizes the Rem statement even without the colon.

  • In VBA using the VBA editor, if you “comment out” a line, that line and all of its line continuations are affected. In VBScript, the comment keyword or symbol must be added to each line to be “commented out.”

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required