Solved

Custom Controls using a generic interface

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

785 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