Siebel VB Language Reference > VB Language Reference >

Chr Function

This standard VB function returns the one-character string corresponding to an ANSI code.





An integer between 0 and 255 representing the ANSI code for a character


The character represented by charcode.


The dollar sign ($) in the function name is optional. If it is included, the return type is string; otherwise the function returns a variant of vartype 8 (string).


This example displays the character equivalent for an ASCII code between 65 and 122 typed by the user.

Sub Button_Click
   Dim numb as Integer
   Dim msgtext as String
   Dim out as Integer
   out = 0
   Do Until out
      numb = 75
      If Chr$(numb)> = "A" AND Chr$(numb)< = "Z" _
         OR Chr$(numb)> = "a" AND Chr$(numb)< = "z" then
         msgtext = "The letter for the number " & numb  _
            &" is: " & Chr$(numb)
         out = 1
      ElseIf numb = 0 then
         Exit Sub   
         msgtext = "Does not convert to a character; try again."
      End If
End Sub

See Also

Asc Function
CCur Function
CDbl Function
CInt Function
CLng Function
CSng Function
CStr Function
CVar Function
CVDate Function
Format Function
Val Function

Siebel VB Language Reference