Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Commenting

As we’ll see, the Visual Basic compiler understands several different types of comments. The simplest are line comments, which are simply ignored by the compiler.

The most basic type of comment, a LINE COMMENT, begins with a single quote (‘) and ends at the end of the line:

' This is a comment
MyInteger As Int32  'This is a also a comment

As you can see, the single quote comment character can come anywhere on a line. The only rule is that everything after the comment will be ignored. You can type anything you like after the quote; the compiler doesn’t care. But you can’t continue the comment onto the next line, even if you use the line continuation character:

image
image

' This will
' NOT cause an error.

How do you know what to comment? This is what experience has taught the programming community: First, comment everything you think you might not remember in six months. Then go back and comment everything you think you will.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial