Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Constructors for Classes
Every so often I want to create a class in VBA, but VBA doesn't seem to have
the concept of a constructor for the class - so you have to (1) call NEW, (2) makes sure that the caller sets up the object right. I'm sure there's an approach for simulating the above (a pattern). Can someone share it? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Constructors for Classes
There is class initailize which is as close as you will get to a consturctor.
Chip Pearson has a good discussion on instantiating classes... http://www.cpearson.com/excel/ClassModules.htm -- HTH... Jim Thomlinson "Gary F" wrote: Every so often I want to create a class in VBA, but VBA doesn't seem to have the concept of a constructor for the class - so you have to (1) call NEW, (2) makes sure that the caller sets up the object right. I'm sure there's an approach for simulating the above (a pattern). Can someone share it? Thanks! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Constructors for Classes
I wonder if I could do something like make the classes variables private,
then make a public method in a module called "New[Name of Class]" that creates the class...hmm... "Jim Thomlinson" wrote: There is class initailize which is as close as you will get to a consturctor. Chip Pearson has a good discussion on instantiating classes... http://www.cpearson.com/excel/ClassModules.htm -- HTH... Jim Thomlinson "Gary F" wrote: Every so often I want to create a class in VBA, but VBA doesn't seem to have the concept of a constructor for the class - so you have to (1) call NEW, (2) makes sure that the caller sets up the object right. I'm sure there's an approach for simulating the above (a pattern). Can someone share it? Thanks! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Constructors for Classes
Here is a tid bit on declaring varaibles and instantiating objects and such
http://www.cpearson.com/excel/variables.htm Take a look at the section "Don't Use The New Keyword In A Dim Statement" for a little bit of insight into objects... -- HTH... Jim Thomlinson "Gary F" wrote: I wonder if I could do something like make the classes variables private, then make a public method in a module called "New[Name of Class]" that creates the class...hmm... "Jim Thomlinson" wrote: There is class initailize which is as close as you will get to a consturctor. Chip Pearson has a good discussion on instantiating classes... http://www.cpearson.com/excel/ClassModules.htm -- HTH... Jim Thomlinson "Gary F" wrote: Every so often I want to create a class in VBA, but VBA doesn't seem to have the concept of a constructor for the class - so you have to (1) call NEW, (2) makes sure that the caller sets up the object right. I'm sure there's an approach for simulating the above (a pattern). Can someone share it? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Classes | Excel Discussion (Misc queries) | |||
Classes containing Classes | Excel Programming | |||
VBA and Constructors; exist? | Excel Programming | |||
Using Classes in .xla | Excel Programming | |||
Using classes defined in an add-in | Excel Programming |