How to: Add a Comment to Your Code (Visual Basic)
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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.


    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.

© 2015 Microsoft