Quick Interface Question

R

reddog9069

I have an interface that has all abstract methods, except one metho
that I want every implementation of the interface to have.

When I am implementing an interface, do I have to copy the whol
subroutine from the interface to the implementation or is there a wa
to make the implementation call the interface definition of th
subroutine?

Also does anyone have a good resource for interfaces and user define
classes in VBA because I cannot really find any good ones?

Thank
 
R

reddog9069

Does anyone have any good info on interfaces or can someone answer m
quick question
 
S

scattered

reddog9069 said:
I have an interface that has all abstract methods, except one method
that I want every implementation of the interface to have.

When I am implementing an interface, do I have to copy the whole
subroutine from the interface to the implementation or is there a way
to make the implementation call the interface definition of the
subroutine?

Also does anyone have a good resource for interfaces and user defined
classes in VBA because I cannot really find any good ones?

Thanks

Hi,
A good reference on the use of classes in VBA is "The VBA Developer's
Handbook"
http://www.amazon.com/exec/obidos/t...104-9510647-3839928?v=glance&s=books&n=507846

I have never played around with the Implements keyword so I can't
answer your question. Maybe you could post it to a straight VB
newsgroup. You seem to be asking for something like implementation
inheritence, which is not directly supported in VB6 or VBA. There *is*
a trick involving delegation that supposedly provides a work-around,
but I honestly don't recall how it works. Maybe on a VB group (but not
the VB.Net!)you can find an answer.

Hope that helps

-John Coleman

 
R

reddog9069

If it is not directly supported in VBA that is fine. I have no proble
just copying the method into the implementation of the interface, bu
that just seems like a big no no from a programming stand point.
will give that book a look through, next time I am at a book store, o
if it is available at my library I will check it out.

I know on the msdn site they talk about interfaces having both abstrac
and non-abstract components, but they only talk about simple things lik
attributes, or properites and their corresponding get and let methods
but nothing along the lines of complete sub routines or functions.

I know it is so easy in c++ and java, using the virtual keyword, but
cannot figure it out in VBA, so maybe VBA was not designed for thi
complex of a program.

Thank
 
N

NickHK

reddog9069,
All classes that Implement your interface must expose all of the routines
found in the interface.
Whilst the interface will have the signatures of the routines, these
routines will not contain any code.
What each class does within its respective routine is up to you.
After you have typed 'Implements MyInterface" as the top of a class module,
click the combo above and select "MyInterface". In the right combobox you
will now see all the routines that you need to expose.

'Interface ITest
Public Property Let MyText(vData As String)
End Property

Public Property Get MyText() As String
End Property
----------------------------------
'Class cTest
Implements ITest

Private Property Get ITest_MyText() As String
......code
End Property

Private Property Let ITest_MyText(RHS As String)
......code
End Property

That's the way I understand it anyway
I am currently making a set of barcode classes (cEAN8, cEAN13, c2Of5, etc)
that all implement the IBarcode interface: Number, size, check digit etc.
However, how each class calculates the bars for its code is class dependent.

In all, it means that I can:
Dim BarcodeInstance as IBarcode

Set BarcodeInstance = New cEAN13 'or cEAN8 or c2Of5

NickHK
 
S

scattered

scattered said:
Hi,
A good reference on the use of classes in VBA is "The VBA Developer's
Handbook"
http://www.amazon.com/exec/obidos/t...104-9510647-3839928?v=glance&s=books&n=507846

I have never played around with the Implements keyword so I can't
answer your question. Maybe you could post it to a straight VB
newsgroup. You seem to be asking for something like implementation
inheritence, which is not directly supported in VB6 or VBA. There *is*
a trick involving delegation that supposedly provides a work-around,
but I honestly don't recall how it works. Maybe on a VB group (but not
the VB.Net!)you can find an answer.

Hope that helps

-John Coleman

Here is a useful link:
http://www.vbip.com/books/186100172X/chapter_172X_08.asp

Hope that helps

-John Coleman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top