Name
CChar Function
Named Arguments
No
Syntax
CChar(expression
)
-
expression
(required; String) Any string expression
Return Value
A value of type Char
Description
Converts the first character in a string
expression
to a Char data type
Rules at a Glance
CChar extracts the first character of expression and converts it to a Char data type.
Example
MsgBox(CChar("abc")) ' Displays a MsgBox(CChar("56")) ' Displays 5
Programming Tips and Gotchas
If you wish to convert a numeric code to its corresponding Char data type, use the ChrW function.
Like most of the conversion functions, CChar is not actually a function in the Microsoft.VisualBasic namespace. Instead, it is similar to a Visual C++ macro; the compiler translates the function call into inline code.
See Also
Get VB.NET Language in a Nutshell, Second Edition 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.