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. The comment may appear on a line by itself or at the end of a logical statement line.

New in 2005. Visual Basic 2005 includes a new XML Comments feature that lets you decorate your class members with special XML-formatted comments. Visual Studio recognizes and uses these comments to enhance the development environment. To use XML comments, place the insertion point on a blank line in your code, just above a method definition, then type three single-quote marks. Immediately, even before pressing the Enter key, the following template appears.

 ''' <summary> ''' ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> 

Once these parts are filled in with the appropriate content, Visual Studio uses the information to display more verbose IntelliSense details concerning the related method. It also exports the XML content to a documentation file during the compile of the assembly.

Usage at a Glance

  • Text or code commented out using the Rem statement or the 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 activeDoc = New AppDoc: Rem Define the object                                 Rem reference. 

    The colon is not necessary when using the apostrophe as the comment marker:

         Set activeDoc = New AppDoc  ' Define the object reference. 

  • Apostrophes held within quotation marks are not treated as comment markers:

         quotedString = "'This string contains single quotes!'" 

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

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

Version Differences

  • VB 6 allowed comment lines to be connected with the line-continuation character ("_"). In .NET, each comment line must include its own Rem keyword or apostrophe (').

  • XML comments are new with Visual Basic 2005.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

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