ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Class module (https://www.excelbanter.com/excel-programming/291611-class-module.html)

Mark[_36_]

Class module
 
Hi NG

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

Regards
Mark



Bob Phillips[_6_]

Class module
 
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)

"Mark" wrote in message
...
Hi NG

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

Regards
Mark





Tushar Mehta

Class module
 
Search google on the subject:

http://www.google.com/groups?as_q=cl...e=off&ie=UTF-8
&oe=UTF-8&as_ugroup=*excel*&as_uauthors=pearson&lr=&num=20 &hl=en

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , says...
Hi NG

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

Regards
Mark





All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com