DWUTKA at marlow.com
DWUTKA at marlow.com
Mon Mar 15 11:22:54 CST 2004
If you want to use early binding, you can do something like this: (FWControl Class) Option Explicit Property Get SomeValue() As Long End Property Property Let SomeValue(intEnter As Long) End Property Public Function RunSomething() End Function (FWCombo Class) Option Explicit Implements FWControl Dim intTemp As Long Private Function FWControl_RunSomething() As Variant intTemp = intTemp * 2 End Function Private Property Let FWControl_SomeValue(RHS As Long) intTemp = RHS End Property Private Property Get FWControl_SomeValue() As Long FWControl_SomeValue = intTemp End Property Public Function ComboSpecific() intTemp = 100 End Function The combo specific function is going to set the 'SomeValue' property to 100. With late binding, you can use one variable. However, Intellisense won't pick that up. You can, however, use 2 variables, with early binding, to represent the same object. Take the two classes above. FWCombo Implements FWControl. So if we want to work with a FWControl, that has FWCombo specific capabilities: dim fw As FWControl dim fwc As FWCombo set fw=New FWCombo set fwc=fw fw.SomeValue=6 fw.RunSomething msgbox fw.SomeValue fwc.ComboSpecific msgbox fw.SomeValue Note, two variables, pointing to the same object. FW is the 'generic' implemented class, and fwc is the more specific class. Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of John W. Colby Sent: Friday, March 12, 2004 7:13 PM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Framework Discussion - Who's following this 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 -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com