Do we have a multi line comment in VB.net.
I know in Java we have /* */ but that doesn't seem to work here.
-
This is also a duplicate: stackoverflow.com/questions/1909447/… Please first use the search before asking the same question.– JonHFeb 22, 2011 at 20:17
-
there is .. see below my answer– HichemAug 1, 2021 at 12:04
6 Answers
No we dont unfortunately..........
You can do: Ctrl + K, Crtl + C
To uncomment ctrl+k ctrl+u
-
@krum_cho highlight what you want to comment and then ctrl +k and ctrl+c to comment. No other way around it.– JonHFeb 22, 2011 at 20:05
-
2
-
If you don't use VBStudio, you will need to make a macro up in Notepad++ or manually comment out each line. Nov 28, 2015 at 23:00
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
-
4More generally, you should be able to do
#If 0 Then
...#End if
to comment things out. (And put any text after//
).– user1837158Nov 24, 2012 at 16:39 -
6
-
1I tried the #if approach, (VB.Net 2017). The problem is intellisense still kicks in within the #if block and interferes with your typing. Sep 12, 2018 at 11:59
Just hold "alt"+"shift" and move cursor up or down to select lines, and press " ' "
-
2
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.
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
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.
-
Sorry, but the #if AFAC that I describe previously do the same thing that /* */.– schlebeDec 23, 2016 at 7:17