DirectCast Function

Syntax

DirectCast (expr, objtype)

Group

Conversion

Description

Returns the expr's type related to the objtype type. If a type does not exist, a "type mismatch error" will occur.

Parameters

 
ParameterDescription
exprConverts the value of this expression.
objtypeConverts to this type.

Sub Main

Dim V As Object

V = Err

Debug.Print TypeName(DirectCast(V, ErrObject)) ' ErrObject

EndSub

Related Topics