Page

9.3.2- Comment Your Code

Created by Brendan Doss.
Last Updated by Brendan Doss.  

PublicCategorized as 09. Error Handling.

Not yet tagged
<< 9.3.1- Indent Your CodeChapter99.3.3- Use Option Explicit >>

Comment Your Code

This one is very simple. If you write code, then you can't expect anyone else tounderstand it (even yourself a few weeks on) unless you comment it thoroughly.Use the single quotation mark to add a comment. Sensible places for commentsare after variable or procedure declarations, to explain what each part does::

 

Dim strTextBox                      'Text Boxcontaining users name stored here

 

Comments are also useful after loops, to indicate what isbeing repeated, or after Else and End If to indicate whatdecision is being taken by that branch of the code:

 

If varQuestion = "Fax" Then  'If user selectsfax then initiate fax confirmation

...code...

ElseIf varQuestion = "Email" 'If user selectsemail then initiate email confirmation

...more code...

Else                         'Don't send userconfirmation

...yet more code...

End If                       'End of confirmationdecision tree

<< 9.3.1- Indent Your CodeChapter99.3.3- Use Option Explicit >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |