1
votes

I would like to create a usercontrol in VS2015 RC (VB.NET) and use it in VB6.

Most articles talking about such a scenario are pretty aged.

I have just tried the following:

In VS2015 RC (Visual Basic.NET), I have created a new usercontrol and set its property to "COM visible" and compiled a x86 version of it.

However, I could not use the resulting DLL in VB6, the error was "The file can't be referenced".

I can reference the .tlb but I think that does not help me, or does it?

Can anybody lend a helping hand here?

Thank you.

1
It helps you. You must reference the .tlb, it is not embedded in the DLL like it is for native COM components. - Hans Passant

1 Answers

1
votes

Yieah!!! I got it. I had to reference the .tlb, then in VB6 I said:

Option Explicit

Private MyCtrl As VBControlExtender

Private Sub Form_Load()
    Set MyCtrl = Controls.Add("ctrl.UserControl1", "ctrl", Me)
End Sub

Private Sub Form_Resize()
    MyCtrl.Left = 100
    MyCtrl.Width = Me.Width - 300
    MyCtrl.Top = 100
    MyCtrl.Height = Me.Height - 700
    MyCtrl.Visible = True
End Sub