VB.NET: Insert Comments & Description In Code

We always follow some conventions when we are coding. On of the most important one is to provide some comments before important methods which give a brief descrip

ITPro Today

August 2, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

We always follow some conventions when we are coding. On of the most important one is to provide somecomments before important methods which give a brief description about the functionality provided by the methods.

To make this task easier, I've been using this small macro since a long time. In fact I have created an AddIn using the same approach. Here is a cut down version for the Macro. In the Visual Studio Environment, press Alt+F11 to open the Macro Designer. In a Module, paste this macro. The template files for the comments are attached with this article as zip file. Unzip and save these files in "C:TempVSTemplates", or if you want to place it somewhere else, change the path in the line 'strBasePath = "C:TempVSTemplates"'.

To Run this Macro from your code, you have to open the Macro Explorer, for this either you can go to Tools->Macros->Macro Explorer or simply press Alt+F8.

After doing all this, all you have to do is to place your cursor anywhere in the method and Double click on the Macro getting listed in the Macro Explorer. This will insert the comment before the starting of the method you have selected. You just have to provide the additional details.

To change the format of the comments, you can modify the template files which are simple XMLs.

Hope this code will be useful for you.
Please let me know in case you have any suggestions or if it is giving any problem on your systems.

Thanks & regards
Shobhit

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like