Latest web development tutorials

VBScript Asc function

VBScript Reference Complete VBScript Reference

Asc function to the first letter of the string is converted to the corresponding ANSI code and returns the result.

grammar

Asc(string)

参数 描述
string 必需。字符串表达式。不能为空字符串!

Examples

Example 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>

Examples of the above output:

65
97
70
102
50
35

try it"

Example 2

Asc returns the first character in the string ANSI code:

<script type="text/vbscript">

document.write(Asc("W") & "<br />")
document.write(Asc("W3CSchool.com"))

</script>

Examples of the above output:

87
87

try it"

Example 3

How to Return a string all the characters in the ANSI code:

<script type="text/vbscript">

txt="W3schools.com"
for i=1 to len(txt)
document.write(Asc(mid(txt,i,1)) & "<br />")
next

</script>

Examples of the above output:

87
51
115
99
104
111
111
108
115
46
99
111
109

try it"

VBScript Reference Complete VBScript Reference