I have been studying VBA for Access, and the latest chapter was on class modules. So far, I think that I have a pretty good grasp on how to create one (at least for a beginner). However, the point that I'm stuck on, is what benefits are there to class modules over plain modules? I think that I need to understand this to know when to use each one. I get that class modules are run on a per instance basis, allowing the same code to be used for different instances. The only time that I can think of where this would be used would be the Recordset class. Since this one is already created, where else would this ability be used? I have searched online and found that the people who have learned class modules, use them all the time. One person said that the more complex the program, the more likely it would be better done in a class module. An example was given that compared writing one line of code instead of 50. In the context that he was talking, the 50 lines of code went into the class module and the one line was when it was called (or instantiated, whichever is the proper term). However, public functions/subs in regular modules have this same ability. The examples found in my book were simplified to the point that I don't understand why go through the hassle to learn class modules since a function or a sub would work perfectly.
I know that there has to be a good reason for class modules, but so far I haven't been able to figure it out. I'm not needing to know how to use them, just why.
I know that there has to be a good reason for class modules, but so far I haven't been able to figure it out. I'm not needing to know how to use them, just why.
Comment