Solved

Interface Implements Interface

Posted on 2006-11-07
2
683 Views
Last Modified: 2008-01-09
In Visual Basic 6.0 / Visual Basic for Applications, is there a way to have an interface extend another interface?  For example, suppose that there is a class module named InterfaceA that contains the following code:

    Public Sub MyMethod()
    End Sub

Now suppose that there is a class module named InterfaceB that contains the following code:

    Implements InterfaceA
    Public Sub InterfaceA_MyMethod()
    End Sub

When I write another class module that contains the following code:

    Implements InterfaceB
    Public Sub InterfaceB_InterfaceA_MyMethod()
    End Sub

I get the following error message when I compile:

    Compile error:

    Object module needs to implement 'InterfaceA_MyMethod' for interface 'InterfaceB'

Could you please tell me what I am doing wrong?  Thank you.
0
Comment
Question by:deatc
2 Comments
 
LVL 4

Accepted Solution

by:
JRCSystems earned 250 total points
ID: 17894843
Yeah, isn't this fun.
VB cannot and will not implement an Interface that has an _Underscore already in it.

Because B --> implemented A, which was MyMethod.
B's implementation of A is InterfaceA_MyMethod.
You MAY have complicated the situation by making that PUBLIC.
Typically, as Sick as it sounds, that stuff is PRIVATE, and jumped into via a V-table through a Type Library.

Try making you PUBLIC Sub InterfaceA_MyMethod, PRIVATE.
Believe it or not, this should solve it.

You MAY want to also try putting in class "C" this:
Implements InterfaceA
Implements InterfaceB

Ultimately, its the _ in the name that's killing the implementation.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question