Go Premium for a chance to win a PS4. Enter to Win


Multiple Levels of interfaces???

Posted on 1998-11-17
Medium Priority
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...

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 13

Accepted Solution

Mirkwood earned 600 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: 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.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

916 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