Class module

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi NG

Just out of curiosity. What is the difference between a module and a class
module.

Regards
Mark
 
A class module is used to define an object, and will have properties and
methods associated with that object defined in there (the attributes of the
object, and the actions that can be performed on/'by it). Using the familiar
example, you might have an employee class, with name, age, sex, grade
properties, and maybe a method to calculate bonus, wage increase, etc. The
properties can be read and/or write.

A module is normally where you would store the common or shared procedures,
ones that may be used even by the class, but do not define a (that) object
themselves.

You use a class like so

Dim myEmp as clsEmployee

Set myEmp = New clsEmployee

with myEmp
.Forename = "Bill"
.Surname = "Wallis"
.DOB = "12 Jun 1976"
.Sex = "M"
.AddLine1 = "37 Acacia Avenue"
'etc
End With

You now have an instance of an employee with many details that you can
access directly. YOu could then put that employee into another class, a
collection class of employees ... but too much too soon perhaps.

By the way, userforms and worksheet code modules are also special calls
modules, defining the form or the worksheet they are associated with.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top