• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 627
  • 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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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