In Vb, the Chr
function is the complement to the Asc function. Chr
returns the character that corresponds to the ANSI code specified as its argument.
Syntax
Chr(intANSICode) ChrB(intANSICode) ChrW(intANSICode)
Normally, the intANSICode
argument must be in the range of 0 to 255. However, on DBCS systems, the actual range for the integer
parameter is -32768 to 32767.
The Chr
function of Vb is useful for specifying characters that you cannot type at the keyboard, such as special control codes for the printer. Another good use for this function is generating double quote marks in strings. Because Visual Basic uses double quotes to delimit strings, you cannot include a double quote mark in a string directly. You can use Chr(34)
to produce a double quote mark within a string, however.
Vb Chr Function Example
Dim strDoubleQuote as String strDoubleQuote = Chr(34)