Advertisement

easy newbie question

Started by May 06, 2000 10:24 PM
5 comments, last by gumball 24 years, 7 months ago
In VC++ version 6, is there a button or command to comment a selected block of code?
No.

If you do not use the C-Style block comments inside your code, than these will work nicely. Here''s an example in case you don''t know.

Change this:

////////////////
// MY COMMENT BLOCK
//
// DESC BLAH BLAH
// BLAH BLAH BLAH
// BLAH.
///////////////

To this:

/*
MY COMMENT BLOCK

DESC BLAH BLAH
BLAH BLAH BLAH
BLAH.
*/

if you DO use the block comment already and your trying to block out a section, there isn''t a one step solution. But there are some simply practices. The easiest is to simply have a tmep file open which is NOT added to the project, then cut and paste your offending code to the temp file, save it... and go on...when you want it back cut and paste it back into the original file...if it''s trash, delete it.
Advertisement
Then there is


#ifdef 0

....stuff you don''t want compiled

#endif


Because there are not any nested code blocks.
Thanks for those, but I was hoping there was a toolbar button that would allow you to select a block of code then click the button to automatically comment it.

This button exists in VB, I thought there may be one in VC++.

Does anyone have a macro to do this instead?

Anything that speeds the coding process is always good
You cau use the CommentOut sample macro adding it as a button in a toolbar.
Open the Tools menu and select Customize.
Select "Add-ins and Macro files" tab and click on the check box to enable the Sample macros.
In the Command tab, select "All commands" in the category list and then search for the CommentOut command into the commands list.
Drag the CommentOut macro over a toolbar and drop it (you can specify either a icon and description).
I posted on this a couple of weeks back. The CommentOut macro looks handy, but it has -never- worked for me. It keeps saying "cannot recognise the file type". Blah.

Edited by - Kylotan on 5/7/00 6:39:13 AM
Advertisement
The CommentOut macro works for me.

I tried to create an UnComment macro by editing the CommentOut macro and changing:
ActiveDocument.Selection = "/*" + ActiveDocument.Selection + "*/"


to this:
ActiveDocument.Selection = Mid(ActiveDocument.Selection,3,Len(ActiveDocument.Selection - 2))

but it did not work.

Anyone got any ideas?

This topic is closed to new replies.

Advertisement