Multiple Levels of interfaces???

Posted on 1998-11-17
Last Modified: 2011-09-20
Ok, this would be easy in say C++, but I'm not sure how I do this in VB (I've very new to the language).

Alright the senario is that I have a group of classes that I want to descend from two interfaces.  No problem.

But four of the group I want to decend from two of the classes that descend from the one of the first two interfaces.

So What I want is:



(Gee, I hope that doesn't look to bad in a browser.)  BTW, I'm using MS's notation where a solid line means subclass of, or for VB Implements.  

At anyrate when I put "Implements ClassFoo" in classBar. I get an error with something like (not verbatum since VB just crashed) "ClassBar must implement procedure InterfaceFoo_ClassFoo_ProcedureName of ClassFoo."  Even if I have a procedure named InterfaceFoo_ClassFoo_ProcedureName.

I can't find anything in the help, nor anyone who can help in physical space.  I think I'm miss understanding the notation that VB wants.

Please help,
Sucking on the juices of feature creep
Question by:rknapp
  • 3
  • 2

Expert Comment

ID: 1445265

i'm assuming that, since you're designing a non-trivial inheritance relationship between your classes, that you've written OO code in a REAL, ahem - i mean *another*, language.

if so, then what i'm guessing you're trying to do is allow, for instance, CBar to inherit CFoo.  Unfortunately, though, VB doesn't really allow this.  all you can inherit is the interface, not the implementation.

on the other hand, you *could* use delegation to "inherit" CFoo's methods from within CBar.

Try using the class builder utility... you'll see that, to get the diagram you want, what VB does is create an instance of the sub-class as an instance variable of the super-class.  sigh.


Author Comment

ID: 1445266
(My languages of choice are C++ or Java  (well, real Java anyway :) ))

I see your point, and I've used that(delegation) in MS-Access (bleck)
to create rudimentary customer "objects."

What I'm really interested in is the typing, I was hoping to get away
with a real simple object typing scheme:
If typeof blahCurrentBlah is ClassUglyMask Then ...

instead of
  if typeof blahCurrentBlah is ClassBoo Then
    Select Case BlahCurrentBlah.BlahObjectType
    Case rjkClassUglyMask
          Dim TmpMask as ClassUglyMask
          Set TmpMask = BlahCurrentBlah
    Case rjlClassScream
        Dim tmpScream as ClassScream
        Set tmpScream as ClassScream
    End select

( It's not so clear in this example, but I need it in what I'm doing and the second option is just plan painful to my hands. :) )

Is there a more elegant way that I'm missing here?

Thanks for your help
Thinking that if he was writing in Java he could email it
to his mac at home, and it might just work!

Expert Comment

ID: 1445267
yeah, i hear you wrt 100% java, as opposed to 100% "embraced" java...

what is it that you want to do in each of your cases? can you encapsulate the functionality in a method in the interface, implementing it in each class either as a delegate or as its own functionality?  then, you could get away with setting an interface reference, and calling the interface method...

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

LVL 13

Accepted Solution

Mirkwood earned 200 total points
ID: 1445268
What you want is not possible in VB.
VB does not support class inheritence. So you cannot inherited implementations of another class.
VB does not support interface inheritence either. You can implement multiple interface with the implements statement but that is where it ends.
Implements just means that you implement that certain interface.

Author Comment

ID: 1445269
Mirkwood --
   Thanks for the answer, it's not what I wanted to hear but what I was expecting. :(

Staplehead --

   I'm working on laboratory software, I've deteremined there are (roughly)  four sample-related and three non-sample related results each with a slightly different (default) calculation that needs to be reported to the user....  Oh WOW!!!  If I get rid of the ISampleRelated and INonSampleRelated and just have all of them implementing IResult that'll solve my problem.  One Interface (well two really there is ApplicationCapsule, but that's not relevant to the discussion) and it'll work right!     Thanks!  Is there anyway I gave give you points as well?   That question gave me a work around for the whole thing!!!!!!!  OH OH The adrenaline is flowing, I gotta go CODE!

Jumping up and down in his chair

Expert Comment

ID: 1445270
Yup! you got it!  the sad thing is, that 'workaround' is the way MS says OOD *should* work in VB!

anyway, i disagree with mirkwood, unless i misunderstand his comment... although you can't "inherit" in a classical sense, you can delegate in order to mimic the semantic features of inheritance.  

as far as the points go, you could open another question, or you could ask cust support to rescind the answer.  unless you're willing to open a dummy question, don't worry about it...


p.s., how'd the coding go?

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 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