View Full Version : Solved: What's the use of a class module
zagrijs
04-30-2013, 04:34 AM
I am unable to work out the use of class modules as they seemed to be private by default and I am unable to call any procedures in a class module from a form or another module.
So what's the use of a class module?
:doh:
Aflatoon
04-30-2013, 04:39 AM
You simply declare any routines that should be public as Public.
zagrijs
04-30-2013, 04:46 AM
Thanks for your reply.
The procedures are declared public. No Luck!
For an example how to use a class module have a look over here:
http://www.snb-vba.eu/VBA_Userform_invoercontrole_en.html
zagrijs
04-30-2013, 05:04 AM
Thanks, snb. It will take some time to digest, but like the link you provided about my post regarding renaming modules, this information open new doors.
Aflatoon
04-30-2013, 06:12 AM
My guess would be that you weren't creating an instance of the class when trying to call its methods?
A Class Module is a blueprint of a custom Object. Once you have defined the custom object, you have to create, (Instantiate,) the object with the New keyword, just like creating a new Collection. Then you can use any custom methods, Properties, and Events just like with any other Object.
Dim X As New Collection
With X
.Add(Item, Key)
,Add(Item,Key)
End With
Z = X.Count Dim Y As New c_MyClass
With Y
.CustomMethod(Parameters) 'Private Sub
End With
Z = Y.CustomProperty 'Property Get Sub
zagrijs
04-30-2013, 09:37 AM
I used custom classes in dBase, quite different from this. I appreciate all the replies and assistance. It opens new doors that I will certainly explore and would put to good use.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.