How to: Add a Comment to Your Code (Visual Basic)
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

How to: Add a Comment to Your Code (Visual Basic)

This example shows comments occupying an entire source code line, part of a line, and more than one line.

' This entire line is a comment. 
Dim DailyTotal As Decimal = 0   ' Sales total for today.
' This comment is so long that it requires more than one line, so  
' the comment character (') must be repeated on the second line.

This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Visual Basic Language. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).

This example requires:

  • A reference to the System namespace.

    NoteNote:

    You cannot continue a comment using the line-continuation sequence ( _). You must repeat the comment character (') at the beginning of each line of a comment.

Show:
© 2016 Microsoft