TryCast Function

Syntax:

TryCast(expr,objtype)

Group:

Conversion

Description: Returns expr's type is related to objtype type. If it is not, nothing will be returned.

Parameters:

Parameter

Description

expr

Cast the value of this expression.

objtype

Cast to this type.

Example:

Sub Main
   Dim V As Object

    V = Err

    Debug.Print TypeName(TryCast(V, ErrObject)) ' ErrObjectEndSub

See Also:

CType, DirectCast