"Static" Methods in Class Modules

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
 
C

Chip Pearson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top