Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lack of block comments in VB .NET?

Just a question of interest: Does anyone know why there's no block comment capability in VB .NET? (Unless there really is - but I've never yet come across it.)

like image 366
froadie Avatar asked Feb 04 '10 00:02

froadie


People also ask

How do you block comments in Visual Basic?

There is no block comment in VB.NET. You need to use a ' in front of every line you want to comment out. Save this answer.

How comments are given in VB net?

In VB . NET, you write a comment by writing an apostrophe ' or writing REM . This means the rest of the line will not be taken into account by the compiler.

What are block comments in code?

Block comments delimit a region of source code which may span multiple lines or a part of a single line. This region is specified with a start delimiter and an end delimiter. Some programming languages (such as MATLAB) allow block comments to be recursively nested inside one another, but others (such as Java) do not.

How the comments are represented in VB?

As you read the code examples, you often encounter the comment symbol ( ' ). This symbol tells the Visual Basic compiler to ignore the text following it, or the comment. Comments are brief explanatory notes added to code for the benefit of those reading it.


2 Answers

It is a side-effect of the Visual Basic syntax, a new-line terminates a statement. That makes a multi-line comment pretty incompatible with the basic way the compiler parses the language. Not an issue in the curly brace languages, new-lines are just white space.

It has never been a real problem, Visual Basic has had strong IDE support for a very long time. Commenting out multiple lines is an IDE feature, Edit + Advanced + Comment Selection.

like image 137
Hans Passant Avatar answered Sep 23 '22 13:09

Hans Passant


Totally abusing compiler directives here... but:

#If False Then
Comments
go
here
#End If

You don't get the benefits of proper code coloration (it doesn't show in green when using the default color scheme) and the implicit line-continuation system automatically indents lines in a paragraph starting at the second line. But the compiler will ignore the text.

like image 26
user665301 Avatar answered Sep 25 '22 13:09

user665301