Visual Basic Concepts

Creating Interfaces for Use With the Implements Statement

When you create interfaces for use with the Implements statement, you can use Visual Basic or any tool that creates type libraries, such as the MkTypLib utility or the Microsoft Interface Definition Language (MIDL) compiler.

Most classes created in Visual Basic define interfaces that work with Implements. When you create an interface by defining a class in Visual Basic, simply make sure that none of the properties or methods have underscores in their names.

Interfaces created with tools other than Visual Basic must follow certain restrictions in order to work with Implements. The following list includes most of these restrictions.

Warning   If you're creating a type library in order to make a system interface usable with Implements, you must not use the [oleautomation] or [dual] attributes. Type libraries must be registered before you can add them to the Visual Basic References dialog box, and registering a type library with the [oleautomation] attribute will overwrite information required to remote the system interface. This will cause other applications on the system to fail. The [dual] attribute must not be used because it implies [oleautomation].

Note   It may be useful to specify [oleautomation] while creating the typelib, in order to enforce correct types, but the type library must be built without the attribute before you reference it through the Visual Basic References dialog box.

For More Information   See "Polymorphism" in "Programming with Objects" in the Programmer's Guide, and also "Providing Polymorphism by Implementing Interfaces" in "General Principles of Component Design" in Creating ActiveX Components in the Component Tools Guide.