Name
Chr, ChrB, ChrW Functions
Syntax
Chr(charactercode) ChrB(charactercode) ChrW(charactercode)
charactercodeUse: Required
Data Type: Long
An expression that evaluates to either an ANSI or Unicode character code.
Return Value
Chr, ChrB, and
ChrW return a variant of the string type that
contains the character represented by
charactercode.
Description
Returns the character represented by
charactercode.
Rules at a Glance
Chr returns the character associated with an ANSI character code.
ChrB returns a one-byte string.
ChrW returns a Unicode character.
Programming Tips and Gotchas
Use
Chr(34)to embed quotation marks inside a string, as shown in the following example:
sSQL = "SELECT * from myTable where myColumn = " & Chr(34) & _
sValue & Chr(34)You can use the ChrB function to assign binary values to String variables.
The following table lists some of the more commonly used character codes that are supplied in the call to the Chr function:
Code | Value | Description |
0 | NULL | For C/C++ string functions, the null character
required to terminate standard strings; equivalent to the
|
9 | TAB | Equivalent to the |
10 | LF | Equivalent to the v |
13 | CR | Equivalent to the |
13 & 10 | CRLF | Equivalent to the CWlocal constant. |
34 | " | Quotation mark. Useful to embed quotation marks within a literal string, especially when forming SQL query strings. |
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access