Solved

Comment out a larg block of code

Posted on 2001-08-20
12
579 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: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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 5

Author Comment

by: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: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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

777 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