• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 689
  • Last Modified:

Interface Implements Interface

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
deatc
Asked:
deatc
1 Solution
 
JRCSystemsCommented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now