example how to expose your .Net Controls as COM to other development
environment (in our case VB6 as example).
Create your control library and make it com visible as in picture below
Because we do not have setup for now and for test we should register our library as COM
check the register for COM option to register it
Create some control and make it com visible also give it a ProgId to expose it to out world
Build the project and let test our control in VB6
Create new vb6 exe project . To add our control dynamically onto the form we will use
the VBControlExtender and code looks like that :
Option Explicit
Dim WithEvents objExt As VBControlExtender
Private Sub Form_Load()
'adding our control licens to licences collection
Licenses.Add "InteropControlLib.DotNetControl", "ewrinvcmcoe"
'adding the control to Form
Set objExt = Me.Controls.Add("InteropControlLib.DotNetControl", "DotNetControl1", Me)
objExt.Visible = True
End Sub
Those of you who found this article interesting and want to find more
check out links below :
COM Interoperability in .NET Framework Applications
COM Interop
Thanks for the article.Helped me a lot.
ReplyDeleteThanks for sharing .net control to vb6.
ReplyDeleteVB6 to C#