Solved

Custom Controls using a generic interface

Posted on 2002-04-03
3
137 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a duplicate finder Application 9 122
passing parameter in sql procedure 9 65
Adding to a VBA? 6 77
VBA filters 2 64
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

809 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