A cast expression is used to coerce an expression to a given type. There are specific cast keywords which coerce expressions into the primitive types. There is also a general cast keyword, CType
, which coerces an expression into any type. If no conversion exists from the type of the expression to the specified type, an error occurs. Otherwise, the result is the value produced by the conversion.
CType
(
Expression ,
TypeName )
|(
Expression )
CBool
| CByte
| CChar
| CDate
| CDec
| CDbl
|CInt
| CLng
| CObj
| CShort
| CSng
| CStr