Solved

Custom Controls using a generic interface

Posted on 2002-04-03
3
135 Views
Last Modified: 2010-05-02

I have built several custom controls and have recently had a need to access them in a polymorphic or generic fashion. I would like to known if it is possible to use the implements key word inside of a custom control using a generic interface. I have tried to do this with no success. The problem happens when I try to set the custom control to the generic interface an error for type mismatch occurs.
I have used the implements in many occasions with no problem in regular classes. Maybe Custom Controls do not allow this. Please help. Thank You.
0
Comment
Question by:noah_i
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
ameba earned 100 total points
ID: 6916868
noah_i,
> The problem happens when I try to set the custom control to the generic interface an error for
> type mismatch occurs.

That should work.
Where is your interface class defined?  Make sure it is defined only once and that all your User Controls are using it.

How to use secondary interface methods/properties:

- you cannot access it directly, e.g. if Clear is in IDataEntry interface, you cannot use:
     myBetterTextBox1.Clear

You must define separate variable of the right type:
     Dim de As IDataEntry
     Set de = myBetterTextBox1    ' access user control using IDataEntry interface (=casting)
     de.Clear

The other method is to pass user control to a function:

     Clear myBetterTextBox1

' in bas module
Public Sub Clear(de As IDataEntry)
     de.Clear
End Sub

See also: "How do I use the Implements keyword"
http://www.insteptech.com/techlibrary/vboo.htm#Obj_Implements
0
 

Author Comment

by:noah_i
ID: 7478976
Sorry took so long. Thanks for the info.
0
 
LVL 15

Expert Comment

by:ameba
ID: 7479177
B !?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 43
VBA filters 2 51
Access Object Property from VBA Module in Excel 2010 2 28
VB6 ListBox Question 4 34
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) 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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now