0

I wrote a DLL in C# in VS2012:

namespace COMTest
{
    public class MyClass
    {
        public int Fun()
        {
            return 3;
        }
    }
}

And then I set "Make Assembly COM Visible=True" and in the Build page, I set "Register COM for intercrop". Then create a new VB6 project, add a reference to the generated dll file but failed……Later tried tlb file succeeded but without intellisense after saying "a." (No "Fun" tip)

Dim a As MyClass
Set a = New MyClass
MsgBox (a.Fun())

So my questions are:

1) Why must I refer tlb file instead of dll file? 2) Why no intellisense?

  • Does this answer your question? [IntelliSense in custom COM classes in VBA](https://stackoverflow.com/questions/41162601/intellisense-in-custom-com-classes-in-vba) – StayOnTarget Aug 16 '22 at 11:35

1 Answers1

1

Try placing a check mark in:

Tools->Options->Editor->Auto List Members

If that does not help, then to resolve this problem, define a public interface by using methods and properties that you want to expose in the TLB, and then implement the interface in the class. Also, add the ClassInterface (ClassInterfaceType.None) attribute to the class. As you develop the component, you can use this approach to avoid using the ComVisible(False) attribute.

You can have more details here

Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61
  • Then can you be kind to tell me why refer "tlb" instead of "dll" directly? –  Jan 23 '14 at 07:35
  • follow the link provided for more details – Nadeem_MK Jan 23 '14 at 07:40
  • I read the link, but I still don't know why I should use TLB instead of dll……:( –  Jan 23 '14 at 07:43
  • tlb is the type library, which contains the descriptions of the interfaces of the objects in the component. dll contains the actual implementations of the objects in the component. Given this information, which of the files do you think that intellisense is going to use? :) – BobRodes Jan 23 '14 at 15:12