Look for books by Ted Pattison (with the word COM in the title) and just
read the first few chaptes to get an excellent insight into what interfaces
are and what they do for you.
A short (and wholly inadequate explanation of the implementation of
interfaces follows).
An interface is the external face of what your class can do.
In VB(A) classes are given a default interface which matches the signature
of your class, so say you have a class called MyClass with an Init method,
VB(A) automatically creates an interface (called _MyClass) for that class.
What you can do is create your own interfaces for the class and then use
them. Lets say you had a class which dealt with sales orders (cOrders) you
might implement an interface on this which gave you the customer details for
the order, or the dates relevant to the order, for example create a class
module call it ICustomer and put the following in it:-
Property Let Code(RHS As String): End Property
Property Get Code() As String: End Property
Property Get Name() As String: End Property
Then create a class module call it IOrderDates and put the following in it:-
Property Let OrderDate(RHS As Date): End Property
Property Get OrderDate() As Date: End Property
If you then put the following lines in the cOrders class in the declarations
section
Implements ICustomer
Implements IOrderDates
Then click in the combo at the top which says (General) you'll see 2 new
entries in there ICustomer and IOrderDates.
If you select ICustomer the the lefthand combo box will let you select each
of the properties we declared in the ICustomer interface and similarly with
IOrderdates.
When you've selected all the properties yout cOrders class will look a bit
like this (I've added some commented lines to make it easier to seee where
the interfaces are.
Option Compare Database
Option Explicit
Implements ICustomer
Implements IOrderDates
'************************************************* *
' ICustomer implementation
Private Property Get ICustomer_Code() As String
End Property
Private Property Let ICustomer_Code(RHS As String)
End Property
' ICustomer implementation
'************************************************* *
'************************************************* *
' IOrderDates implementation
Private Property Get IOrderDates_OrderDate() As Date
End Property
Private Property Let IOrderDates_OrderDate(RHS As Date)
End Property
' IOrderDates implementation
'************************************************* *
You can now do things like
Dim cO as cOrders
Dim iC as ICustomers
Set cO = New cOrders
Set iC = cO
' At this point you can start using teh ICustomers interface
With iC
.Code = "xxxyyy"
Msgbox .Name
End with
Set iC = nothing
Set cO = nothing
In your cOrders class module you can then write code in the interfaces as
you normally would in order to achieve the results you want.
--
Terry Kreft
MVP Microsoft Access
"Brian O'keefe" <ra*********@yahoo.com> wrote in message
news:42**********@127.0.0.1...
Implements? Interfaces?
Man, I wish I had that level of sophistication... chuckle.
Sadly, all the OOP I know I have learned on my own. And nothing I have
needed to know has mentioned interfaces or implements. Oh, I have SEEN
them when perusing manuals and books, but I have so little time to do
what I want that I tend to spend the time I have learning what I NEED to
know.
SO if you can explain, in the textbox given you for a reply on this
board, why I would want to use an Interface or Implement and then where
I can learn this online?
I would REALLY appreciate it...
Thanks for replies all...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!