"Static" Methods in Class Modules

  • Thread starter Thread starter Ripan
  • Start date Start date
R

Ripan

Is there anyway to create static methods in VBA Class Modules. By this
mean methods that can be accessed from outside the Class Module withou
making an instance of the object.

As a more concrete example:

I have a class module to hold a Time (a value for hour, minute, an
AM/PM). I declare various variables that are instances of the Tim
object. I want to see if one time is before another but I do no
necessarily want to have to create an instance of a Time Object to d
that. (I want to be able to call functions by using Time.x as you ca
do in regular Methods).

I know this is possible in the C# and C++ frameworks through the use o
Static Methods. Is it possible in VBA?

Thanks for any help
 
Ripan,

You must instantiate the object based on the class before you can
call any of its methods. Otherwise, you'll get an error 91.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top