Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Block comments

Status
Not open for further replies.

Ladyhawk

Programmer
Joined
Jan 22, 2002
Messages
534
Location
AU
I have always wondered why VB can not do block comments in a similar fashion to C++ (i.e., the /* and */ syntax). I wonder if this is a conscious omission by Microsoft or do they think that VB programmers don't deserve the benefits and ease of use of block comments.

Is there any way of defining symbols so that they can be used as block comments? Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Ladyhawk,

The use of the apostrophe that VB uses at the start of any comment goes back to VB's "mother tongue", QuickBasic, and was used to keep VB retro-compatible with this language. It may go further back to previous Basic languages. I suspect the /* */ used by C/C++ to set off a block of text goes back to earlier versions of C, although I don't know this to be true.

To be honest, having written code in QuickBasic 4.5 originally, I could never get used to the C/C++ notation, especially when blocks of comment text took up more than a screen (yeah, I'm a demon for in-code documentation). I frequently deleted the first line of the comment text and then forgot to delete the rest of it. The next attempt to run the code would, of course, fail.

It might be interesting to develop a function in VB to do the same thing.

The Missinglinq "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
How would one develop such a function? Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Ladyhawk,

Just found out you don't need to; VB's already done it!

1) If you don't have the Edit Toolbar showing, go to View, Toolbars, then select Edit.

2) Type in your lines of comments

3) Hi-lite (select) all the comment lines

4) Go to the Edit toolbar

5) Run your cursor around until you find a control named "Comment Block" & click on it

6) Your lines will all be marked as comment lines now

7) There's also a control on the Edit toolbar named "Uncomment Block" that reverses
the process.

The Missinglinq "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Yeah I know VB has that.. but I wanted to block comment in the code. Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
I'm confused; what do you mean by " I wanted to block comment in the code"? "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
I wanted to be able to type something like:

/* This is my
block comments
blah blah blah */

rather than having to have

' This is my
' block comments
' blah blah blah Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
An alternative might be to use the apostrophy for the first line and the line continuation character (underscore) for the following lines, as in:

'This is a valid comment _
appearing on more than one line. _
Of course, you DO need to rember to have the _
continuation char (and the space) at the end _
of each line. I SUPPOSE that many would say that _
this is no different from having the comment char at _
the start of each line, but I find that editing the _
comments to be a bit easier.
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top