Javascript Functions to Mimic VB Asc and Chr Functions CodeUnit 07 JUL 2009

If you come from a VB programming background, often you are left floundering when trying to retrieve character codes from a string or vice versa, trying to convert character codes into a string value when using Javascript.

The following two javascript functions are designed to mimic the more familiar Asc and Chr functions found in the VB language:

//returns numeric character code from string character
function Asc(String){
return String.charCodeAt(0);

//returns string character from numeric character code
function Chr(AsciiNum){
return String.fromCharCode(AsciiNum);

There, you should feel a tad more comfortable now.

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.