Rem Statement

   
Rem Statement

Syntax

 Rem   comment     ' comment   
comment (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

  • Text or code commented out using either the Rem statement or an apostrophe is not compiled into the final program and, therefore, does not add to the size of the executable.

  • If you use the Rem statement on the same line as program code, a colon is required after the program code and before the Rem statement. For example:

     Set objDoc = MyApp.MyObj : Rem Define the object                            Rem reference 

    This is not necessary when using the much more common apostrophe:

     Set objDoc = MyApp.MyObj   ' Define the object reference 
  • Apostrophes held within quotation marks are not treated as comment markers, as this code snippet shows:

     myVar = "'Something'" 

Programming Tips and Gotchas

  • The Visual Studio development environment contains block-comment and block-uncomment buttons on the Text Editor toolbar, which allow you to comment out or uncomment a selection of many rows of code at once.

  • You cannot use the line-continuation character ("_") with comments.

VB.NET/VB 6 Differences

In VB 6, if a line containing a comment ends in an underscore (the line continuation character), the following line is interpreted as a comment as well. In VB.NET, line continuation characters are ignored at the end of a comment line; each comment line must be prefaced with the Rem statement or the ' symbol.

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net