?
Solved

Custom Controls using a generic interface

Posted on 2002-04-03
3
Medium Priority
?
146 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

829 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