vba difference between type of and type name?

Well gol dang -- an informative morning. Thank you Rory and Colin.
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Just to help you with the next step and using the code in #6 as an example:

cTest is inheriting from I1 and I2 and it must implement all of the public members from I1 and I2 otherwise you'll get a compile error. Any members in I1 and I2 which are below Public scope (eg Friend, Private) do not need to be implemented.

If you start with cTest being empty except for the two Implements statements, to quickly get all of the stubs it needs to implement, you can use the dropdown boxes at the top of the code module (top left box for I1 and I2, top right box for the members of each). When you do that you'll get the I1_foo and I2_foo methods automatically populated in the cTest class module.
 
Upvote 0
... and it must implement all of the public members from I1 and I2 otherwise you'll get a compile error.

That's useful behavior.

Thanks, Colin, I create custom classes infrequently, but am saving this thread for future reference.
 
Upvote 0
Have you ever used interfaces in an Excel environment in a real world scenario?

I've only ever seen one and it was far from necessary. How often are custom objects/code created in excel that have the level of complexity to justify an interface? I'd guess at not very often, and if the code is sufficiently complex enough to warrant one, wouldn't there probably a better platform than Excel to begin with? I get that they're a hangover from VB6 so have always assumed they aren't really used in an Excel environment.

Now if we were talking about real inheritance, that would be something I could understand the usefulness of ;)
 
Upvote 0
I can't say I have but it doesn't need a lot of complexity - it just adds flexibility. You might create a progressbar interface for example and then use different implementations of it (eg statusbar or userform) without having to alter any calling code.
 
Upvote 0
Thanks Rory

It was a progress bar I'd seen actually from an article on EE.

I understand the benefit of interfaces, especially in a multi-coder environment, the layer of abstraction is useful. Similar to writing sprocs for developers to use rather than dynamic sql, you don;t have to worry about how it works, just know the inputs and outputs.

That said, my question was more along the lines of whether the technique is actually used in the "wild" for Excel, I haven't experienced any environments where spreadsheet code is maintained by more than one person. More likely is the scenario where the workbook gets passed person to person as the creator moves on, since "VBAers" tend to be self taught (and run a mile when a class is involved), I usually stick to the KISS methodology if I know someone else will be maintaining something I've stuck together. (Though having said that I have put together a couple of very Object Orientated workbooks together due to business logic/db interaction being too complex to just script and expect people to maintain - also to keep coding short too ;))

I'm just curious to know whether people actually use them or whether they're one of those techniques that you can theoretically see a use for, can understand their usefulness, but ultimately when you face a scenario when you could use them, you usually find a better way. ( I had one of those for ages where I thought building an ADO recordset from excel data that allowed me to filter and do all sorts of useful stuff with seemed like a useful thing to do, but when I actually found a situation that I could use this in I found a better way ) anyway - ramble over ;)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,086
Messages
6,128,736
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top