View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK[_3_] NickHK[_3_] is offline
external usenet poster
 
Posts: 415
Default Curious - What is Implements used for

Mike,
The way I use Implements means that you can have a generic variable that is
used for different implentations of the interface.
So, in the example, we know that any varialbe declared as IBarcode will have
the guarateed methods/properties.

'< Class IBarcode
Private Property Get cbarCode_CodeNumber() As String
'Stub signatures only
End Property

Private Property Let cbarCode_CodeNumber(RHS As String)
'Stub signatures only
End Property
'</ Class IBarcode

'< Class cCode2of5
Implements IBarCode
Private Property Get cbarCode_CodeNumber() As String
'Code specific to cCode2of5
End Property

Private Property Let cbarCode_CodeNumber(RHS As String)
'Code specific to cCode2of5
End Property
'</ Class cCode2of5

'< Class cEAN13
Implements IBarCode
Private Property Get cbarCode_CodeNumber() As String
'Code specific to cEAN13
End Property

Private Property Let cbarCode_CodeNumber(RHS As String)
'Code specific to cEAN13
End Property
'< Class cEAN13

' VBA code
Dim MyBarCode as IBarCode

Set MyBarCode = New cEAN13
'and/or
Set MyBarCode = New cCode2of5

This works because Implements is a contract that each class will expose all
the same signatures that exist in the Interface.

NickHK

"Mike" bl...
Hi,

Just out of curiousity / desire to learn, can someone explain to me what
Implements is useful for?

The way I read the example, variables were defined in one class, then two
classes that Implement that first class have to define all the properties
to
cover those variables - does that mean that the only thing implements does
is save you from having to declare the variables in the other 2 classes?
either the example is too simple, or I'm just missing something.

I guess the reason I ask is I was trying to find a way to define a class
for
my charts with a "standard" reaction to events (standard for my particular
app), and then for specific charts override some of those events, and I
stumbled across implements, but I'm not sure if that's what I'm looking
for... and now I'm curious.

Thanks,

mike.