2.6. Documenting Your Code
It is a good idea to document your code very well so that you and others will be able to understand the purpose of each procedure and why it was written in a certain way. You can document your code in several ways. The ideal way to document your code is to use a general comment section at the beginning of each procedure and to use in-line comments to describe each segment of code. Here is an example of such a general comment section.
'***************************************************************** '* '* Procedure Name: TestProcedure '* '* Purpose: The purpose of this procedure is to illustrate why '* documenting your code is so important. '* '* Parameters: None. '* '* Date Created: September 4, 2006 '* By: Denise M. Gosnell '* '* Modification Log: '* Date Explanation of Modification Modified By '* ------------ ---------------------------------- ------------------------ '* '******************************************************************
The preceding documentation style may be overkill if the procedure itself is only a few lines of code. Some type of general comment section should be used with all procedures, even if it is not as detailed as the one in the preceding code.
You have seen in-line comments in all the code examples throughout this chapter. Here is another example:
'display a message to the user Msgbox "Demonstration of In-Line commenting"
It is always better to write too many comments than too few. As you gain more experience writing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access