[AccessD] Framework Discussion - Who's following this

John W. Colby jwcolby at colbyconsulting.com
Fri Mar 12 19:13:17 CST 2004


Drew,

I am open to interfaces, assuming that you can present a case for a
significant advantage.  What do I gain by implements?  Other than being able
to treat the objects as a custom type (class) rather than an object what
have I gained?  Am I getting early binding out of this so that Intellisense
works?  If so can I "get at" all of the class properties, i.e. not just
those implemented?

IOW, if I say:

	Set FWObj = New FWComboBox

can I then say FWObj.ComboClassSpecificProperty?

That would definitely be cool, and powerful.

At the moment when I pass an object, I get late binding so I can't really
tell if I am getting a valid method, passing valid parameters etc. until I
test it out at runtime.

Implements and interfaces adds another level of complexity that even I don't
understand.  My audience here may already be struggling with just figuring
out classes and withevents.  If I am going to throw in Interfaces and
Implements (and learn it myself) it has to be for a darned good reason.

John W. Colby
www.ColbyConsulting.com


Something I'd like to ask, in an earlier post, you were explaining how you
were 'linking' your Class objects.  Just out of curiousity, why not do
something like this:

FrameWorkControl Class:
Option Compare Database
Property Set LinkedObject(objTemp As Object)

End Property
Public Function CleanUp()

End Function
Property Get ObjectName() As String

End Property
Property Get ObjectType() As String

End Property

FWComboBox Class:
Option Compare Database
Implements FrameWorkControl
Dim WithEvents lnkObject As ComboBox
Private Function FrameWorkControl_CleanUp() As Variant
Set lnkObject = Nothing
End Function
Private Property Set FrameWorkControl_LinkedObject(RHS As Object)
Set lnkObject = RHS
lnkObject.OnClick = "[Event Procedure]"
End Property
Private Property Get FrameWorkControl_ObjectName() As String
FrameWorkControl_ObjectName = lnkObject.Name
End Property
Private Property Get FrameWorkControl_ObjectType() As String
FrameWorkControl_ObjectType = "ComboBox"
End Property
Private Sub lnkObject_Click()
MsgBox lnkObject.Name
End Sub

FWTextBox Class:
Option Compare Database
Implements FrameWorkControl
Dim WithEvents lnkObject As TextBox
Private Function FrameWorkControl_CleanUp() As Variant
Set lnkObject = Nothing
End Function
Private Property Set FrameWorkControl_LinkedObject(RHS As Object)
Set lnkObject = RHS
lnkObject.OnClick = "[Event Procedure]"
End Property
Private Property Get FrameWorkControl_ObjectName() As String
FrameWorkControl_ObjectName = lnkObject.Name
End Property
Private Property Get FrameWorkControl_ObjectType() As String
FrameWorkControl_ObjectType = "TextBox"
End Property
Private Sub lnkObject_Click()
MsgBox lnkObject.Name
End Sub

Example Form Code:
Dim FrameWorkObjects As Collection
Private Sub Form_Load()
Dim FWObj As FrameWorkControl
Dim ctrl As Control
Dim blValidControl As Boolean
Set FrameWorkObjects = New Collection
For Each ctrl In Me.Controls
    blValidControl = False
    If TypeOf ctrl Is TextBox Then
        Set FWObj = New FWTextBox
        blValidControl = True
    End If
    If TypeOf ctrl Is ComboBox Then
        Set FWObj = New FWComboBox
        blValidControl = True
    End If
    If blValidControl Then
        Set FWObj.LinkedObject = ctrl
        FrameWorkObjects.Add FWObj, FWObj.ObjectName
        Set FWObj = Nothing
    End If
Next
End Sub
--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list