• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 606
  • Last Modified:

Comment out a larg block of code

How do I comment out a large block of code at once?

In C++ you can do something like:

/*
...
...
Large block of code
...
...
*/

and the whole block will be commented out.  The compiler ignores everything between the /* and the */

How does this work in VBA?
0
Tom Knowlton
Asked:
Tom Knowlton
  • 3
  • 3
  • 3
  • +2
1 Solution
 
nico5038Commented:
Only an insert of a single quote per line or just "disabling" a whole SUB by changing the name ;-(
are the ways I know.

Nic;o)
0
 
devthaCommented:
if you want to block from line 3 to 10 then insert a blank line on line 3 and write


line 2
If false then    'now line 3
 line 2  'old line 3
  ..
  ..
  ..
  ..
  line 10
end if
0
 
devthaCommented:
that was an example of how you can achieve it faster without going to each line and commenting or uncommenting them out...
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
Tom KnowltonWeb developerAuthor Commented:
Your suggestions are both good, but they are work-arounds.

The VBA IDE does not have this built-in???
0
 
GudareCommented:
The VBA IDE doesn't have that built in *for Access* until the XP version.

Fastest way: Cut/paste to Excel VBA IDE. Hit comment selection, cut/paste back.

-Craig
0
 
maatthiasCommented:
You can add this feature to a menu.  Check out this article http://support.microsoft.com/support/kb/articles/Q171/3/88.ASP
0
 
maatthiasCommented:
In short,
In module or form design window, right-mouse click your toolbar, choose Customize..., under Commands tab, choose "Edit".  Find "Comment Block" and "Uncomment Block".  You can drag these to, for example, your Debug menu.
0
 
Tom KnowltonWeb developerAuthor Commented:
maatthias:

Bingo!

Thanks!
0
 
GudareCommented:
DOH... um, thanks maathias. I'm gonna go sit in the corner and bang my head on the wall now...

-Craig
0
 
devthaCommented:
knowlton did it work as this article is not for access.
0
 
GudareCommented:
Devtha: It works for AC2k, not 97, in case he doesn't come back since he closed it.

-Craig
0
 
maatthiasCommented:
Specifically, it will with VBA 5.0 and up.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now