Solved

Custom Controls using a generic interface

Posted on 2002-04-03
3
134 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
Comment Utility
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
Comment Utility
Sorry took so long. Thanks for the info.
0
 
LVL 15

Expert Comment

by:ameba
Comment Utility
B !?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

16 Experts available now in Live!

Get 1:1 Help Now