Chr - VBScript
Chr
Overview
The Chr command in VBScript converts an ASCII code to its corresponding character. This can be useful for various tasks, such as displaying special characters in a text output or working with character-based operations.
Syntax
Chr(number)
Parameters:
- number: Integer value representing the ASCII code of the character to be obtained.
Options/Flags
None.
Examples
- Displaying a special character:
WScript.Echo Chr(13) & "New line"
- Generating a string with repeated characters:
Dim str
str = String(10, Chr(42)) 'String of 10 asterisks
WScript.Echo str
Common Issues
None.
Integration
- With the String function: The Chr command can be used with the String function to create strings filled with specific characters.
- With other character-based functions: The Chr command can be used with other character-based functions in VBScript, such as Asc (converts a character to its ASCII code) or Left (extracts a specified number of characters from the left of a string).
Related Commands
- Asc: Converts a character to its ASCII code.
- Left: Extracts a specified number of characters from the left of a string.