Block commenting VB/VB.NET code

Viewed 48195

How to comment multiple lines of code/block of code in VB?

12 Answers

VB doesn't have such a construct at the language level. It has single line comments using apostrophe character:

' hello world
' this is a comment
Rem this is also a comment

However, Visual Studio has a functionality to automate this task. Select the lines you want and press Ctrl+K+C for commenting and Ctrl+K+U for uncommenting (General Development Settings shortcuts, look at the "Edit -> Advanced" menu while selecting some code to see the shortcuts).

The other answers explain how to comment/uncomment automatically in VB.NET. Just for completeness, in VB6 use these toolbar buttons: alt text. More details here.

Select the lines you need to comment and press keys CTRL+K+C.

If you need to uncomment use CTRL+K+U

In the vb++ you can comment the blocks of the comment with:

CommentStart==>Type your comment and on many of the lines<==CommentEnd+/inc.

in VS2010 VB.NET, type 3 times ' above a class/function/property/declaration

then it will auto generate a comment block :

''' <summary>
''' GRP Business partner ID
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>

same thing in C# but type 3 times /

/// <summary>
/// 
/// </summary>
Related