DirectCast Function

Syntax:

DirectCast(expr, objtype)

Group:

Conversion

Description: 

Returns expr's type is related to objtype type. If it is not, a "type mismatch error" will occur.

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.PrintTypeName(DirectCast(V, ErrObject)) ' ErrObject
End
Sub