Name
CType Function
Synopsis
CType(expression
,typename
)
expression
required; anyThe data item to be converted
typename
required; KeywordThe data type, object type, structure, or interface to which
expression
is to be converted
Named Arguments
No
Return Value
expression
cast as a
typename
interface, object, structure, or
data type
Description
Converts an expression to the specified data type if possible;
expression
can be any data, object,
structure, or interface type. typename
can
be any data type (such as Boolean
,
Byte
, Decimal
,
Long
, Short
,
String
, etc.), structure type, object type, or
interface that can be used with the As
clause in a
Dim
statement. If the function fails, or if the
converted value of expression
is outside
the range allowed by typename
, an
InvalidCastException exception occurs.
Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.