logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 How to quickly (really quickly) comment out blocks of code

Posted on
2/18/2001
Author:
Robert Gelb
Email:
Not Shown
Applies To OS:
All
Product:
5, 6



From the files of Stupid Keyboard Tricks

Since version 1.0 VB lacked a block comment feature that C/C++ programmers love so dearly.  Finally in version 5, the mothership provided us with half of the solution - one could now go to the Customize menu and add the Comment Block and Uncomment Block button to the toolbar or the menu.  And that was good.  But if you are a keyboard jockey like us, you want something faster and preferably something faster than the /*...*/ operator in C/C++.  This is the story of how to do it:

  1. Right click on the toolbar and select Customize... menu
  2. Under Categories click on Edit, then select Comment Block in the Commands listbox.
  3. Now drag the Comment Block entry onto the Menu Bar (yep! the menu bar)
  4. You should now see a new icon on the menu bar. 
  5. Make sure that the new icon is highlighted (it will have a black square around it) and click Modify Selection button on the Customize dialog box.
  6. An interesting menu will popup.  Under name, add an ampersand to the beginning of the entry.  So now instead of Comment Block it should read &Comment Block.  Press Enter to record the change.
  7. Click on the Modify Selection button once again and select Image and Text.
  8. Dismiss the Customize dialog box.
  9. Now highlight any block of code and press Alt-C.  Voila.
  10. Do the same thing for the Uncomment Block or any other commands that you find yourself using often.

ToolbarEditor With Commented Out Block

 


Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word:
 



Comments
#1. By Anonymous. Posted on 3/7/2006 10:41:02 AM
this is stupid

#2. By Anonymous. Posted on 3/8/2006 7:54:35 AM
Reply to #1. Stupid or not, it gets the job done. I've been using this since VB6, into VS.NET 2002, 2003 and 2005. There isn't a faster way to uncomment stuff.

#3. By Anonymous. Posted on 5/12/2006 4:23:23 PM
Wonder who the Hack is that said this is stupid?? Obviously someone too stupid to know better. Works great thanks for the tip.

#4. By Anonymous. Posted on 7/4/2006 4:26:45 AM
it helps. it's better than nothing.

#5. By ghh3rd. Posted on 8/9/2006 9:15:17 PM
Glad I stumbled onto this. I found that there's already a button on the Excel VBA toolbar to do this that I wasn't aware of. No more waking up my co-workers with my repetitive clicking while I'm commenting or uncommenting many rows of code.

Granville

#6. By Mimo. Posted on 11/23/2006 1:40:08 AM
a real jockey u r
many thanks 4 u

#7. By Anonymous. Posted on 12/15/2006 6:50:51 AM
Thanks a lot, this really helps when it comes to testing different methods of code :D

#8. By Anonymous. Posted on 1/5/2007 6:02:45 AM
Nice tip, not just for comment/uncomment but also for customizing shortcuts to other actions. Thanks!

#9. By Peter. Posted on 2/2/2007 5:54:35 PM
Oh, yes!!!

This was the most useful thing I've read all day. I've been in per-line commenting hell for months. The tip on customization and the keyboard shortcut are both just as awesome too. Thanks so much!

#10. By world. Posted on 3/18/2007 2:16:53 AM
hello world http://bcreditused.info http://carloanp.info http://refincarloan.info http://badcredith0melan.info http://creditcard0ffer.info

#11. By Chris. Posted on 6/20/2007 5:30:56 PM
This is great!! I didn't even know that Excel had this feature... I was used to C# easy context-menu comment/uncomment... happy to find this back in Excel! This is a real time saver!

#12. By John. Posted on 9/19/2007 5:48:07 PM
somestrangetextvista

#13. By Anonymous. Posted on 9/26/2007 3:26:22 PM
Quote:
#1. By Anonymous. Posted on 3/7/2006 10:41:02 AM
this is stupid
________________________________________________

You're stupid, you probably have no idea what is discussed here...

Robert, GREAT TIP ! Thanks a bunch, really helps!

#14. By Anonymous. Posted on 11/13/2007 9:40:30 AM
There is another to do it:
- insert before the first line to be changed to comment
#If false Then
- insert after the last line to be changed to comment
#End If

#15. By ghh3rd. Posted on 11/13/2007 9:57:55 PM
Hey anonymous...

Thanks for the additional tip to use:

#If false Then
- insert after the last line to be changed to comment
#End If

It works great!

GHH

#16. By g_p_k_. Posted on 12/17/2007 7:46:09 AM
For this tip, I truly love you...

#17. By Anonymous. Posted on 2/19/2008 10:32:45 PM
',down,left,',down,left,',down,left,',down,left,',down,left,',down,left,',down,left,',down,left,',down,left,',down,left,',down,left, MAN I WISH I KNEW THIS SOONER HAHAHA

Thanks so much

#18. By Anonymous. Posted on 7/4/2008 10:42:56 AM
fantastic! sped up my copious debugging of the rubbish code I generate no end.