Export (0) Print
Expand All

Char Data Type

Char variables are stored as unsigned 16-bit (2-byte) numbers ranging in value from 0 through 65535. Each number represents a single Unicode character. Direct conversions between the Char data type and the numeric types are not possible, but you can use the AscW and ChrW functions for this purpose.

Appending the literal type character C to a single-character string literal forces it to the Char data type. This is required if the type checking switch (Option Strict) is on, as the following example shows:

Option Strict On
' ...
Dim CharVar As Char
CharVar = "Z"    ' Cannot convert String to Char with Option Strict On.
CharVar = "Z"C   ' Successfully assigns single character to CharVar.

The equivalent .NET data type is System.Char.

See Also

Data Type Summary | Char Structure | Integer Data Type | Type Conversion Functions | Conversion Summary | Implicit and Explicit Conversions | Efficient Use of Data Types | Asc, AscW Functions | Chr, ChrW Functions

Show:
© 2014 Microsoft