18

Possible Duplicate:
commenting VB code
Lack of block comments in VB .NET?

How to?

Is there a way to comment out more than one line of code in vb.net using VS 2010?

Community
  • 1
  • 1
sarsnake
  • 26,667
  • 58
  • 180
  • 286

6 Answers6

32

The only way is to highlight the lines to comment and press

ctrl + k, ctrl + c

or after highlighted press the toolbar option to comment out the selected lines.

The icons look like this enter image description here

nickmoriarty
  • 1,253
  • 19
  • 21
21

I just learned this trick from a friend. Put your code inside these 2 statements and it will be commented out.

#if false

#endif
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
user1985128
  • 219
  • 2
  • 2
15

Highlight block of text, then:

Comment Block: Ctrl + K + C

Uncomment Block: Ctrl + K + U

Tested in Visual Studio 2012

Chris Jacob
  • 11,878
  • 7
  • 47
  • 42
10

multi comment in vb.net

VB.NET doesn't support for multi line comment.

The only way to do multi-line comments in VB.NET is to do a lot of single line comments(').

Or just highlight the whole code and just use (Ctrl+E,C), (Ctrl+E,U) to comment or uncomment.

Only in c# /* */

Or in ASP.NET html source using <!-- -->.

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Crimsonland
  • 2,194
  • 3
  • 24
  • 42
1

The only way I could do it in VS 2010 IDE was to highlight the block of code and hit ctrl-E and then C

1

Create a new toolbar and add the commands

  • Edit.SelectionComment
  • Edit.SelectionUncomment

Select your custom tookbar to show it.

You will then see the icons as mention by moriartyn

A_Sea
  • 23
  • 3