krum_cho
krum_cho

Reputation: 485

multiline comment in vb.net

Do we have a multi line comment in VB.net.
I know in Java we have /* */ but that doesn't seem to work here.

Upvotes: 39

Views: 80665

Answers (6)

schlebe
schlebe

Reputation: 3716

In Visual Basic .Net 2008 and 2010, I use the following C++ Workaround.

#If AFAC Then

#End if

For English speaking AFAC = "à effacer" = "to delete"

I already use #If COMMENT or #If TODO

The #if COMMENT then solution is more powerful than the C++/Java/C# /* text */ solution because it is possible to nest #if but not /* !!!

For more information see the following link

Upvotes: 14

Hichem
Hichem

Reputation: 1182

you can do on all visual studio version ..

#Region "mycomment"
 'comment line1
 'comment line2
#End Region

you will be able to hide and show the entire block

enter image description here

Upvotes: 3

Wizard
Wizard

Reputation: 171

Just hold "alt"+"shift" and move cursor up or down to select lines, and press " ' "

Upvotes: 6

Nate Koppenhaver
Nate Koppenhaver

Reputation: 1702

Only single-line comments are possible in VB, unlike C/C++ and it's derivatives (Java, JavaScript, C#, etc.). You can use the apostrophe " ' " or REM (remark) for comments like this:

Sub Main()  
    ' This is a comment  
    REM This is also a comment  
End Sub  

But there is no multi-line comment operator in VB, unless you count using the keyboard shortcuts like @JonH and @Tedd Hansen said.

Upvotes: 1

Tedd Hansen
Tedd Hansen

Reputation: 12314

Not possible. Write your chunk, select it and press Ctrl+K, Ctrl+C to comment it.

But it doesn't always matter as often you use ''' in front of a method or property to describe it. Then it will automatically create the comments for you.

Upvotes: 2

JonH
JonH

Reputation: 33153

No we dont unfortunately..........

You can do: Ctrl + K, Crtl + C

To uncomment ctrl+k ctrl+u

Upvotes: 52

Related Questions