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
  • PrintPrint
Share this Page URL
Help

Hour 15. Debugging Your Code > Adding Comments to Your Code

Adding Comments to Your Code

One of the simplest things you can do to reduce bugs from the beginning—and to make tracking down existing bugs easier—is to add comments to your code. A code comment is simply a line of text that Visual Basic knows isn’t actual code and therefore ignores. Comment lines are stripped from the code when the project is compiled to create a distributable component, so comments don’t affect performance. Visual Basic’s code window shows comments as green text. This makes it easier to read and understand procedures. Consider adding comments to the top of each procedure, stating the procedure’s purpose. In addition, you should add liberal comments throughout all procedures, detailing what’s occurring in the code.

Did you Know?

Comments are meant to be read by humans, not by computers. Strive to make your comments intelligible. Keep in mind that a comment that’s difficult to understand isn’t much better than no comment at all. Also remember that comments serve as a form of documentation. Just as documentation for an application must be clearly written, code comments should also follow good writing principles.



  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint