O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Explicit Data Conversion

What happens if you need to convert a Double to an Integer, and you know that the magnitude of the Double value is within the range of acceptable values for the Integer data type? If the implicit conversions would be the only mechanism available, you would be stuck. But they are not. An explicit conversion is a transformation function that takes a data type and transforms it into another data type. There are a number of conversion functions available in the Visual Basic language, some of which are in Table 7.1.

Table 7.1. Conversion Functions in Visual Basic .NET
Name Converts To Comments and Parameter Range
CByte Byte 0 to 255 (same as for Byte data type)
CShort Short Same as for Short data type
CInt Integer Same as for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required