Excel VBA Class Properties

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

I have gathered that a class eg Employee can have properties eg Employee.Address and Employee.Number

So Once I instantiate a new Employee I can assign properties
eg Employee.Address = "31 Crescent Way....

but what is the use of this as when the class terminates this dissapears. How are these properties beneficial? Are they meant to be used in further conditional code or stored in a database etc?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi, murbro.

You don't terminate the class until you're finished with the data or you have saved it (whether that be to a sreadsheet, file or whatever). In that sense, it's no different to an ordinary variable.

Regards,
Brian.
Most Valuable Expert 2011
Top Expert 2011
Commented:
Typically, you would use classes in Excel to implement the business logic part of your application. That way you keep that separate from the interface and the storage, so it makes no difference to the class what your database is (Excel, Access, SQL and so on) or how you create the data (worksheet, userform whatever). How you create the objects and what you do with them may vary but the class itself is impervious to that. (and equally, as long as the interface is the same, the actual class code may change without affecting the consumers of the class.)
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial