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 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:\Temp\VSTemplates", or if you want to place it somewhere else, change the path in the line 'strBasePath = "C:\Temp\VSTemplates"'.

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

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish