|
|
|
|
||
A simple example<< Back to Classes index pageIntroductionIn this first example, we will create a very basic class module which we'll call clsSimple. We'll give it some properties that we can set and change using normal VBA code.We'll also show how to use the Stop command in test code to leave us "live" in memory.
Hint: Before starting, make sure these boxes are ticked in the
Coding Options area of the Tools > Options > Modules menu:
Instructions
What we've learnedThis very simple example has shown us how to create a custom object clsSimple with properties OrderID, CustomerName and Value, and then set those properties and do something with them - even if it's only printing them out again. Creating a property is as simple as declaring a public variable in the Class Module code. It's also shown us how to set up a test program to leave us 'live" in the Debug Window to do test and other mischief with our objects. MoreAs a further example, just open the Debug Window again (Ctrl+G) and type the following commands: Set os = New clsSimple ? os.Value __ os.Value = 199.99 ? os.Value __ ? os.CustomerName __ os.CustomerName = "Barney" ? os.CustomerName __ ? os.OrderID __ os.OrderID = 33 ? os.OrderID __ You have just created a new object called os on the fly. The command that did this was Set os = New clsSimple Because you aren't "live" in a procedure, you won't get prompted with the auto list this time, but you are still able to assign and retrieve its properties. More questions
Feedback or questions: Contact DI Management. Return to Tips and Tutorials Page. |
|
|
| Copyright © 2000-5 DI Management Services Pty Limited ABN 78 083 210 584 Sydney, Australia. www.di-mgt.com.au. All rights reserved. | |
|
Home | What We Do | Services | Our Approach | About Us | Projects | Tips | Links | Cryptography | About This Site | Contact | Email Us |