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...

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

578 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