I.T. Discussion Community!
-Collapse +Expand
Access
Search Access Group:

Advanced
-Collapse +Expand Access To/From
To/FromCODEGuides
-Collapse +Expand Access Store
PRESTWOODSTORE

Prestwood eMagazine

December Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Access & VBAAccess VBALanguage Basics   Print This     
Next Random Article Next Random Tidbit || Change Topic Random From All
  From the January 2016 Issue of Prestwood eMag
 
Access Language Basics:
Access VBA Comments (' or REM)
 
Posted 11 years ago on 11/14/2008 and updated 1/29/2009
Access Code Snippet:
 A flashcard from our Access Flashcards Library
 A code snippet from our Access Code Snippets Page

KB101499

Languages Focus: Comments

Commenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.

Access VBA Comments

Commenting Code
Access VBA, like all the VB-based languages, uses a single quote (') or the original class-style basic "REM" (most developers just use a quote). Access VBA does NOT have a multiple line comment.

Directives - #

Directives are sometimes called compiler or preprocessor directives. A # is used for directives within Access VBA code. Access VBA offers only an #If..then/#ElseIf/#Else directive.

Syntax Example:
'Single line comment.

REM Old school single line comment.

#If MyDirective Then
'...some code.
#End If

Multi-Line Comment Code Trick

You can simulate a multi-line comment with code which is useful especially if you wish to comment out a block of code.

For example:

If False Then
 '...code here skipped.
End If

Using Directives

Here is a simple example of using VB Classic's directive (change True to False to switch it).

#Const MyDirective = True

#If MyDirective Then
      MsgBox ("Yes")
#Else
      MsgBox ("No")
#End If

More Info


Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1162A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #101499 Counter
22184
Since 11/14/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech