Dela via


Character Data Types

Visual Basic provides character data types to deal with printable and displayable characters. While they both deal with Unicode characters, Char holds a single character whereas String contains an indefinite number of characters.

For a table that displays a side-by-side comparison of the Visual Basic data types, see Data Type Summary (Visual Basic).

Char Type

The Char data type is a single two-byte (16-bit) Unicode character. If a variable always stores exactly one character, declare it as Char.

For more information, see Char Data Type (Visual Basic).

String Type

The String data type is a sequence of zero or more two-byte (16-bit) Unicode characters. If a variable can contain an indefinite number of characters, declare it as String.

For more information, see String Data Type (Visual Basic).

See Also

Tasks

Troubleshooting Data Types

How to: Hold Characters in a Variable

Concepts

Composite Data Types

Generic Types in Visual Basic

Typeless Programming in Visual Basic

Type Characters

Other Resources

Elementary Data Types

Data Type Implementation

Type Conversions in Visual Basic