CHR

CHR(charcode)

Returns the character with the corresponding ASCII / ANSI number (Variant / String).


charcodeThe number that identifies a character (Long).

REMARKS
* This function can be used to return both printable and unprintable characters.
* Numbers from 0 - 31 are the same as standard, nonprintable ASCII codes.
* For example, Chr(10) returns a linefeed character.
* The normal range for number is 0 - 255.
* If "charcode" > 256, then a run-time error is generated.
* You can use the ASC function to return the ASCII / ANSI number for the first character in a text string.
* You can use the ASCW function to return the Unicode number for the first character in a text string.
* You can use the CHR$ function to return a String data type instead of a Variant data type.
* You can use the CHRB function is used with byte data contained in a String.
* You can use the CHRB$ function to return a String data type instead of a Variant data type.
* You can use the CHRW function to return the character with the corresponding Unicode number.
* The equivalent Excel function is Application.WorksheetFunction.CHAR
* The equivalent .NET function is Microsoft.VisualBasic.Strings.Chr
* For more information, refer to the ANSI Characters page.
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print Chr(9)           '= tab  
Debug.Print Chr(10) '= line feed
Debug.Print Chr(13) '= carriage return
Debug.Print Chr(32) '= space
Debug.Print Chr(65) '= "A"
Debug.Print Chr(70) '= "F"
Debug.Print Chr(90) '= "Z"
Debug.Print Chr(97) '= "a"
Debug.Print Chr(122) '= "z"

Dim lCode As Long
lCode = Chr(100) '= "d"
Debug.Print lCode

Debug.Print Chr(Asc("A")) '= "a"

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top