Microsoft KB Archive/186914

= How To Implement Additional Interfaces in an ActiveX Control =

Article ID: 186914

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q186914



SUMMARY
This article demonstrates how to implement an additional interface in a Visual Basic ActiveX control. ActiveX EXE and DLL components are better suited for this purpose, but it may be desirable, for example, to implement a custom interface that is present in all of your ActiveX controls. That is the approach taken in the example shown in this article.



Step-by-Step Example
  Start a new ActiveX DLL project in Visual Basic. Change the name of the project to BaseClass. Change the name of Class1 to CustomInterface. Insert the following code into the CustomInterface class module: Public Function testCustomInterface End Function

  On the File menu, click Add Project to add a new ActiveX Control project. Click References on the Project menu, and check the reference to BaseClass. Insert the following code into the General Declarations section of the UserControl's code module: Implements BaseClass.CustomInterface

Private Function CustomInterface_testCustomInterface As Variant CustomInterface_testCustomInterface = _ "Custom Interface test successful." End Function

Public Function testStandardInterface As Variant testStandardInterface = "Standard Interface test successful." End Function

 Change the name of the project to interfacesControl. Click Add Project on the File menu to add a new Standard EXE project. Right-click on Project1 in the Project window and select the Set as Start Up option. On the Project menu, click References, and then check the reference to BaseClass. Place the UserControl (interfacesControl) on Form1. Add a CommandButton to Form1.  Insert the following code into the General Declaration section of Form1: Private Sub Command1_Click

Debug.Print Me.UserControl11.testStandardInterface

Dim obj As BaseClass.CustomInterface Set obj = Me.UserControl11.Object Debug.Print obj.testCustomInterface

End Sub

 Run the project, click Command1 and note that both interfaces responded in the Immediate Window,.</ol>

Additional query words: kbDSupport kbDSD kbActiveX kbClientServer kbVBp500 kbVBp600

Keywords: kbhowto KB186914

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.