VBScriptAsc函数

Asc 函数把字符串中的第一个字母转换为对应的 ANSI 代码,并返回结果。
语法
Asc(string)
参数 | 描述 |
---|---|
string | 必需。字符串表达式。不能为空字符串! |
实例
实例 1
<script type="text/vbscript"> document.write(Asc("A") & "<br />") document.write(Asc("a") & "<br />") document.write(Asc("F") & "<br />") document.write(Asc("f") & "<br />") document.write(Asc("2") & "<br />") document.write(Asc("#") & "<br />") </script>
以上实例输出结果:
65 97 70 102 50 35试一试
实例 2
Asc 返回字符串中第一个字符的 ANSI 代码:
<script type="text/vbscript"> document.write(Asc("o") & "<br />") document.write(Asc("qianmu.net")) </script>
以上实例输出结果:
111 114试一试
实例 3
如何返回字符串中所有字符的 ANSI 代码:
<script type="text/vbscript"> txt="qianmu.net" for i=1 to len(txt) document.write(Asc(mid(txt,i,1)) & "<br />") next </script>
以上实例输出结果:
114 117 110 111 111 98 46 99 111 109试一试
