Asc Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE



The Asc function converts the first letter in a string to ANSI code, and returns the result. Its parameter is string which describes the string as an expression and there cannot be a empty string. The Asc function might seem obscure at first - who wants to know the ASCII code for characters? But this actually can become quite important in data processing. Sure, if you're wondering if a character is the letter A you can just do a straight comparison if LetterInput = "A" then ...but there are special characters that can end up in strings that are much harder to test for. The two most notorious are the carriage return and the line feed. These are ASCII strings 10 and 13. They can cause all sorts of formatting problems and cause your parsing to go haywire. To use the Asc function, you feed in a character and it returns the numeric ASCII ID of that character.

CodeNum = ASC (LetterInput)
if CodeNum = 10 or CodeNum = 13 then response.write "Invalid Entry"


The Syntax of Asc Function is :-

Asc (string)

Example#1 :-

Code :-
document.write(Asc("A") & "<br />")
document.write(Asc("F"))
Output :-
657

Example#2 :-

Code :-
document.write(Asc("a") & "<br />")
document.write(Asc("f"))
Output :-

97102

Example#3 :-

Code :-
document.write(Asc("W") & "<br />")document.write(Asc("virtualsplat.com"))
Output :-
8787

Example#4 :-

Code :-
document.write(Asc("2") & "<br />")
document.write(Asc("#"))
Output :-
5035

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641