Using Type Conversion Functions

Table 6-1 lists functions built into Visual Basic .NET for converting one data type to another. These functions accept arguments of almost any data type and convert them to the types listed. If the conversion isn’t possible, the function raises an exception.

Table 6-1. Visual Basic .NET Type Conversion Functions

Result Data Type

Function

Description

Integer

Asc

Converts the first letter in a string to a number between -32,768 and 32,767 or, if the operating system doesn’t support double-byte characters, between 0 and 255. Asc("A") returns 65, the ASCII (and Unicode) value for A.

Integer

AscW

Converts the first letter in a string to a number between 0 and 65535.

Boolean

CBool

Returns False

Get Faster Smarter Beginning Programming 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.