Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Scripting
VBScript
 Chr Function

  Switch on low bandwidth view
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
Visual Basic Scripting Edition
Chr Function

Updated: March 2009

Returns the character associated with the specified ANSI character code.

Chr(charcode)

The charcode argument is a number that identifies a character.

Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character.

The following example uses the Chr function to return the character associated with the specified character code:

Dim MyChar

' Returns A:
MyChar = Chr(65)   
' Returns B:
MyChar = Chr(66)   
' Returns Z:
MyChar = Chr(90)   

' Returns a:
MyChar = Chr(97)   
' Returns b:
MyChar = Chr(98)   
' Returns z:
MyChar = Chr(122)  

' Returns 0:
MyChar = Chr(48)   
' Returns 1:
MyChar = Chr(49)   
' Returns 9:
MyChar = Chr(57)   

' Returns horizontal tab:
MyChar = Chr(9)
' Returns >:
MyChar = Chr(62)   
' Returns %:
MyChar = Chr(37)   
NoteNote:

The ChrB function is used with byte data contained in a string. Instead of returning a character, which may be one or two bytes, ChrB always returns a single byte. ChrW is provided for 32-bit platforms that use Unicode characters. Its argument is a Unicode (wide) character code, thereby avoiding the conversion from ANSI to Unicode.

Reference

Date

History

Reason

March 2009

Added more examples.

Information enhancement.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
All the letters of the alphabet in a combobox in vb.net      Dierick L   |   Edit   |   Show History
Dim i As Integer
For i = 97 To 122
cboLetter.Items.Add(Chr(i))
Next
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker