
Variables | 61
Variables and
Data Types
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
CShort Function
Converts any numeric expression in the range of a
Short to Short, rounding
any fractional part.
CSng Function
Converts any numeric expression in the range of a Single to Single.
CStr Function
Converts an expression to its string representation. Boolean values are
converted to either “True” or “False.” Dates are converted based on the date
format defined by the regional settings of the host computer.
CType Function
Provides generalized casting, allowing an object or expression of any type to
be converted to another type. It works with all classes, structures, and inter-
faces. This applies to both the basic data types and custom classes. The
function has the following syntax:
CType(expression, typename)
For instance, the statement:
Dim targetNumber As Integer = CType("12", Integer)
is equivalent to:
Dim targetNumber As Integer = CInt("12")
New in 2005. The 2005 release of Visual Basic adds operator overloading
features, described in Chapter 5. One component of operator overloading is
the ability to define
CType conversion rules for your own custom classes.
CUInteger Function
New in 2005. Converts any numeric expression in the range of a
UInteger to
UInteger, rounding any fractional part.
CULong Function
New in 2005. Converts any numeric expression ...