Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Difference between "Module" and "Class Module"

Posted on 2003-10-29
2
Medium Priority
?
850 Views
Last Modified: 2011-10-03
I want to know the difference.
Does anyone know where I can find documents talking about it?
Thanks
0
Comment
Question by:meciab
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
HaydnH earned 200 total points
ID: 9641019
From the Access help files:

_________________________________________________________________

Creating Custom Objects with Class Modules

You can use a class module to create a definition for a custom object. The name with which you save the class module becomes the name of your custom object. Public Sub and Function procedures that you define within a class module become custom methods of the object. Public Property Let, Property Get, and Property Set procedures become properties of the object.

Once you've defined procedures within the class module, you can create the new object by creating a new instance of the class. To create a new instance of a class, you declare a variable of the type defined by that class. For example, if the name of your class is ABasicClass, you would create a new instance of it in the following manner:

Dim abc As New ABasicClass
When you run the code containing this declaration, Visual Basic creates the new instance. You can then apply its methods and properties by using the variable abc. For example, if you've defined a custom method called ListNames, you could apply it as follows:

abc.ListNames
_________________________________________________________________


For more information see the help file section "Program with Class Modules":

 - enter "class module" in the index,
 - "Create a class module that is not associated with a form or report" will appear
 - select "For information on using class modules, click <button>"

Haydn.

0
 
LVL 17

Expert Comment

by:JezWalters
ID: 9641061
A Class module is roughly equivalent to a C++ class (if you're familiar with that).  Each class module effectively defines a data type, composed of the data items it is made up of and a set of procedures that operate on them.

If you define public Property Let, Get or Set procedures you can control access to the data members of your classes (for example, to only permit valid data combinations).  Any other public procedures you specify become methods you can inkvoke on each object of the class type.

Using classes allows you to "hide" complexity and protect data that is "private" to how a particular object works.  Although standard modules can also contain variables and procedures, they cannot be used to define objects.  In other words:

Dim YourObject As YourClassModule     ' Valid
Dim YourObject As YourStandardModule  ' Invalid

If you want more information, look up "class modules" in the Access on-line help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

730 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