VBScript: Conversion and Format Functions - The Asc() Function
(Page 2 of 5 )
The Asc() is used to return the ANSI code for the first character in an expression. Here we use it to display the ANSI code for the letters a through f, both capitalized and lower case:
<html>
<body>
<script type="text/vbscript">
document.write(Asc("A") & "<br />")
document.write(Asc("a") & "<br />")
document.write(Asc("B") & "<br />")
document.write(Asc("b") & "<br />")
document.write(Asc("C") & "<br />")
document.write(Asc("c") & "<br />")
document.write(Asc("D") & "<br />")
document.write(Asc("d") & "<br />")
document.write(Asc("E") & "<br />")
document.write(Asc("e") & "<br />")
document.write(Asc("F") & "<br />")
document.write(Asc("f"))
</script>
</body>
</html>
This gives us the result:
65
97
66
98
67
99
68
100
69
101
70
102
You will note however that I said it gives us the ANSI code for the first character in an expression, so the following will result in the same output as the above, as it still only takes from that first character and not the entire (in this case) string:
<html>
<body>
<script type="text/vbscript">
document.write(Asc("Apple") & "<br />")
document.write(Asc("ape") & "<br />")
document.write(Asc("Banana") & "<br />")
document.write(Asc("baboon") & "<br />")
document.write(Asc("Chinchilla") & "<br />")
document.write(Asc("chaquita") & "<br />")
document.write(Asc("Doscile") & "<br />")
document.write(Asc("digereedoo") & "<br />")
document.write(Asc("Enoch") & "<br />")
document.write(Asc("epoch") & "<br />")
document.write(Asc("Funky") & "<br />")
document.write(Asc("funkay"))
</script>
</body>
</html>
As stated above this gives us the same result:
65
97
66
98
67
99
68
100
69
101
70
102
Next: CBool...CBool Run >>
More Windows Scripting Articles
More By James Payne