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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 76
Paint/Redraw window while dragging 16 78
Change the path of the data source in my Excel pivot table with macro 4 43
TT Auto Dashboard 13 92
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 need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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