3

I have a user control created in a C# solution and I have to use that control in an existing form in VB. I am new to vb. Please help me out in this.

Thanks in advance.

5
  • 1
    Check this link Commented Oct 1, 2013 at 7:07
  • Are you sure? you want to use .net dll in VB? That won't work if .net is not installed? Commented Oct 1, 2013 at 7:18
  • yes. Dotnet is already installed.I am trying to use it like this. Set mctldemo = Controls.Add("Democtl.Control", "ctlDemo", Me) Commented Oct 1, 2013 at 8:57
  • 2
    I feel sorry for you having to still work with VB6. Commented Oct 1, 2013 at 11:46
  • A related answer: stackoverflow.com/a/19092026/1768303 Commented Oct 2, 2013 at 8:35

2 Answers 2

2

I have set the control like this when loading the data:

   Set mctldemo = Controls.Add("Democtl.Control", "ctlDemo", Me)

But forgot to mention the ClassInterface as shown in this link

[ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("Democtl.Control")] 

Thank you all for responding to my question and thank you Nadeem_MK for the link

Sign up to request clarification or add additional context in comments.

Comments

-1

It seems this is not supported. I've never tried - why would I - but others have:

However according to support documents, it may be just barely possible to make it work by hosting the dotNet usercontrol within a WebBrowser instance on the VB6 control.

But I really suggest you don't do that. I can't help thinking it would be easier to upgrade the whole form to dotNet... indeed the whole project to VB.Net...

Alternatively you could rewrite the usercontrol as a VB6 usercontrol.

1 Comment

Aren't your three links are for different problems? (i) displaying a .Net control in an Office document (ii) displaying a .Net form from VB6 (iii) displaying a .Net control from Internet Explorer. The question is about displaying a .Net control (not form) in a VB6 form. BTW upgrading VB6->VB.Net can be a massive undertaking.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.