ASC ASP String Function

ASC ASP String Function
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"


Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.

Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map

Content copyright © 2023 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.