Implementing interfaces in Visual Basic


Though all interfaces can be implemented in C++, this is not the case with Visual Basic. The following are conditions that an interface should meet for it to be implementable in Visual Basic:
  • The interface should inherit from IUnknown or IDispatch. As ICurve inherits from IGeometry, it cannot be implemented in Visual Basic.
  • Method names should not start with an underscore ("_"). You will not find functions beginning with "_" in ArcObjects.
  • All parameter datatypes should be supported by Visual Basic. IActiveView cannot be implemented in Visual Basic for this reason.
While implementing interfaces, IDL parameter attributes are used to decide whether the parameter will be ByRef or ByVal in Visual Basic.
  • Parameters with the [in] attribute are implemented as ByVal parameters.
  • Parameters with the [in,out] attribute are implemented as ByRef.
  • Parameters with the [out,retval] attributes are implemented as return values of the method.
  • Parameters with the [out] attribute are implemented as ByRef.