?
Solved

Interface Implements Interface

Posted on 2006-11-07
2
Medium Priority
?
686 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
JRCSystems earned 750 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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