O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

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

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.

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