VB-Scripting Asc v/s Chr Function

Function Name:- Asc

Meaning :- Used to get ANSI character code of “First” character of the string.

ANSI:- American National Standards Institute. Chart of ANSI

Syntax:- Asc(String)

  • No Arguments are given runtime error occurs

Function Name:- Chr

Meaning :- Used to get character associated with  ANSI character code(Reverse of Asc)

ANSI:- American National Standards Institute. Chart of ANSI

Syntax:- Chr(code)

  • Code :- ANSI number for a character


Example:-

  • Msgbox Asc(“A”) ‘Returns ANSI value = 65 
  • Msgbox Chr(65) ‘Returns character value = A 
  • Msgbox Asc(“ufthelp”) ‘Returns ANSI value of ‘u’ 
  • Msgbox Chr (117) ‘Returns ‘u’ 
  • Msgbox Chr() ‘Throws Exception 
  • Msgbox Asc() ‘Throws Exception

ufthelp

Leave a Reply

Your email address will not be published. Required fields are marked *