[Public|Private|Protected|Friend|Protected Friend]Interface name [Inherits interfacename[, interfacename]] [Property proname] [Event proname] [Function proname] [Sub proname] End Interface
The Interface statement syntax has these parts:
Part | Description |
---|---|
Public | Optional. Entities declared with the Public modifier have public access. There are no restrictions on the use of public entities. |
Private | Optional. Entities declared with the Private modifier have private access. A private entity is accessible only within its declaration context, including any nested entities. |
Protected | Optional. Entities declared with the Protected modifier have protected access. Protected access can only be specified on members of types (both regular type members and nested types), although there are different access rules for the two. A protected type member contained in a type is accessible to entities contained in a derived type, provided the access takes place through the derived type. A protected type nested in a type is accessible to entities contained in a derived type, provided the access takes place through the base type (since nested types are not inherited). Protected access is not a superset of friend access. |
Friend | Optional. Entities declared with the Friend modifier have friend access. An entity with friend access is accessible only within the program that contains the entity declaration. |
Protected Friend | Optional. Entities declared with the Protected Friend modifiers have the union of protected and friend accessibility. |
name | Required. Name of the Interface; follows standard variable naming conventions. |
Inherits | Optional. Specifies that the interface being declared inherits properties and methods from the interface specified by interfacename. |
interfacename | Required if optional Inherits statement is present. Indicates the name of one or more interfaces being inherited. |
Default | Optional. Indicates that the procedure with which the Default keyword is associated is the default property or method for the interface. |
Property | Optional. Indicates a Property procedure that is a member of the interface. |
Function | Optional. Indicates a Function procedure that is a member of the interface. |
Sub | Optional. Indicates a Sub procedure that is a member of the interface. |
proname | Required if optional Property, Function, or Sub statements exist. Indicates the name of the property or procedure. |
The methods and properties of an interface are implemented in a class. When methods are implemented, the return data type and the argument data types must exactly match those of the method described in the Interface block. The method name, however, need not be the same as that described in the Interface block. Methods being implemented in a class cannot be designated as Shared, nor can they be Private, except in a non-inheritable class.
The Interface statement can appear in the declaration section of any module. Interfaces are implicitly Public by default but can be explicitly declared Public, Friend, Protected, Protected Friend or Private.
An interface can have, at most, one default method or property. This implies that an interface can either inherit only one interface containing a default method or property, or its definition block can contain one method or property that is marked as default.
An interface cannot inherit from another interface whose access level is more restrictive than its own. For example, a public interface cannot inherit a friend interface.
Class Statement | Function Statement | Inherits Statement | Sub Statement