60 likes | 139 Views
Code Regions and XML Comments. Code Regions. The code editor automatically puts little minus signs next to the header line for each Sub or Function. You can collapse these procedures to just their headers simply by clicking the minus sign.
E N D
Code Regions • The code editor automatically puts little minus signs next to the header line for each Sub or Function. • You can collapse these procedures to just their headers simply by clicking the minus sign. • You can see this code again by clicking the plus signs.
Code Regions • This is useful when you want to focus on two procedures that work together, but are separated by other procedures in your code. • By shrinking the unaffected procedures, you can compare the ones that you are working on with little or no scrolling.
Creating Your Own Regions • You can add your own regions using the “#Region” directive. For example, if you wanted to identify Tom’s code for assignment 4, you could place a • #Region “Tom’s Code” • At the start, and an • #End Region • At the end of Tom’s code.
Code Regions You can add a comment onto the #End Region so that is easier to identify your regions: #End Region ‘ Tom’s Code
XML Comments • XML comments are typed in the line just above a class, procedure, property, or other declaration in your code. • XML comments are not as easy to read as regular comments, but they are more useful because Visual Studio incorporates them into Intellisense. • If you want to provide the users of your classes with the same type of on-the-spot help with your classes and procedures that VB does with the built-in classes, use XML comments. • To create XML comments for a code block, simply type three single quotes (‘’’) in the line above the declaration and hit Enter. • Visual Studio will fill in the framework for the comment. Simply type in the appropriate descriptions that you want the users of your code (which will probably include you) to see.