The IsA operator appears to be braindead

The IsA operator is supposed to be able to evaluate if obj is an instance of the specified class (or of a derivative class).

However, the operator fails to function when invoked by code defined in a different scope.

For example, a utility function named Cast will not work when called from other script libraries:

Function Cast( obj As Variant, ByVal toType As String ) As Variant

Dim retval As Variant

If obj IsA toType Then

Set retval = obj

Else

Error 1037, “Illegal cast: '” & TypeName( obj ) & “’ is not a '” & toType & “'”

End If

Set Cast = retval

End Function

If this function is defined in script library B and invoked in script library A (for classes also defined in A), it will always fail.

It seems that IsA can only evaluate classes defined in the same immediate context.