Hello.
Does anyone know of, or have, a good tutorial for creating classes (I'm using Excel)?
I know the basics but want to create an event for my class, and eventually to create an event wrapper for
the BeforeDoubleClick event. (This is from an example by C Pearson which I couldn't follow.)
Is it possible (using Excel) to create an object hierarchy?
Thanks in advance, Andy.
Class module - full sample
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Class module - full sample
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 79365
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Class module - full sample
Here are some links:
How to create application-level event handlers in Excel
Creating a Custom Popup Menu
It is possible to use user-defined class objects within other user-defined class objects. I have attached a simple (and stupid) example. There is no interface, just code. To see it in action, run the macro Test and look at the Immediate window.
How to create application-level event handlers in Excel
Creating a Custom Popup Menu
It is possible to use user-defined class objects within other user-defined class objects. I have attached a simple (and stupid) example. There is no interface, just code. To see it in action, run the macro Test and look at the Immediate window.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Class module - full sample
Thank you. That's a nice straight-forward example. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Class module - full sample
Your ClassSample establishes links between instances of the same class; boss and slave are both employees. I'm lookingHansV wrote:Here are some links:
How to create application-level event handlers in Excel
Creating a Custom Popup Menu
It is possible to use user-defined class objects within other user-defined class objects. I have attached a simple (and stupid) example. There is no interface, just code. To see it in action, run the macro Test and look at the Immediate window.
to create a hierarchy between different classes. In particular, I'm creating cEmployee and cCustomer classes and trying to
assign a customer to an employee. Any advice? Could I attach my code or file? Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 79365
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Class module - full sample
You could create a cCustomerRelation class with members of type cEmployee and cCustomer.
But do you have a practical application in mind? It looks like you're trying to create a relational database-like structure. It might be a lot easier to create a database in Access or SQL Server - they have built-in support for relationships between tables.
But do you have a practical application in mind? It looks like you're trying to create a relational database-like structure. It might be a lot easier to create a database in Access or SQL Server - they have built-in support for relationships between tables.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Class module - full sample
Hello.
I'm studying Classes within Excel. I want to create a class (object) that contains another class, presumably called a sub-class.
(Like a Range contains a Font, etc.)
The actual sample is immaterial at this stage.
Thanks, Andy.
I'm studying Classes within Excel. I want to create a class (object) that contains another class, presumably called a sub-class.
(Like a Range contains a Font, etc.)
The actual sample is immaterial at this stage.
Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 79365
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Class module - full sample
The sample workbook I posted higher up in this thread shows how a class object can contain another class object. In this example, the Group object contains two instances of the Employee object, but it could have been an Employee object and a Customer object just as easily. You can also nest more levels.
Best wishes,
Hans
Hans