Solved

Comment out a larg block of code

Posted on 2001-08-20
12
584 Views
Last Modified: 2012-05-04
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
Comment
Question by:Tom Knowlton
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 6407332
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
 
LVL 6

Expert Comment

by:devtha
ID: 6407338
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
 
LVL 6

Expert Comment

by:devtha
ID: 6407341
that was an example of how you can achieve it faster without going to each line and commenting or uncommenting them out...
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 6407342
Your suggestions are both good, but they are work-arounds.

The VBA IDE does not have this built-in???
0
 
LVL 2

Expert Comment

by:Gudare
ID: 6407358
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
 
LVL 4

Expert Comment

by:maatthias
ID: 6407374
You can add this feature to a menu.  Check out this article http://support.microsoft.com/support/kb/articles/Q171/3/88.ASP
0
 
LVL 4

Accepted Solution

by:
maatthias earned 16 total points
ID: 6407392
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
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 6407428
maatthias:

Bingo!

Thanks!
0
 
LVL 2

Expert Comment

by:Gudare
ID: 6407447
DOH... um, thanks maathias. I'm gonna go sit in the corner and bang my head on the wall now...

-Craig
0
 
LVL 6

Expert Comment

by:devtha
ID: 6407568
knowlton did it work as this article is not for access.
0
 
LVL 2

Expert Comment

by:Gudare
ID: 6407582
Devtha: It works for AC2k, not 97, in case he doesn't come back since he closed it.

-Craig
0
 
LVL 4

Expert Comment

by:maatthias
ID: 6407646
Specifically, it will with VBA 5.0 and up.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question