Home > Language Reference > Classes > Object

Implements Function

Determines whether the object implements the features of a given class.

Syntax

Public Function Implements(ByVal lTypeID As Long) As Boolean

ParameterDescription
lTypeIDType identifier.

Remarks

The Implements function determines whether the object it is applied to implements the features of the class specified by the lTypeID parameter. In other words, it checks whether the actual type of the object derives from this class or not, and therefore if the object can be safely casted to this type.

The lTypeID parameter specifies the type identifier of a class. This value is obtained through a call to the TypeID function, and should be considered as opaque. If the actual type of the object derives from this class, the function returns True, otherwise it returns False.

The following example tests whether the methods of the StreamMemory class can be used on an arbitrary stream or not:

Public Sub DoSomeStuffWithAStreamMemory(ByRef s As Stream)
  Dim sm As StreamMemory

  If s.Implements(TypeID(StreamMemory)) Then
    Set sm=StreamMemory(s)
    ' Code that uses sm goes here
  Else
    Err.Raise 1000, "Invalid parameter: StreamMemory expected"
  End If
End Sub

For more information about objects and type conversion, please refer to the Objects section in this documentation.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A