Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

VBScript Asc function


May 13, 2021 VBScript


Table of contents


VBScript Asc function

The VBScript Asc function returns the ANSI character code for the initials of the string.


VBScript Asc function Complete VBScript reference manual

The Asc function converts the first letter in the string to the corresponding ANSI code and returns the result.

Grammar

Asc(string)

Parameters

parameter describe
string Required.String expressions.Can't be empty strings!

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

The above example output results:

65
97
70
102
50
35

Try it out . . .

Instance 2

Asc returns the ANSI code for the first character in the string:

<script type="text/vbscript">

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

</script>

The above example output results:

87
87

Try it out . . .

Instance 3

How to return an ANSI code for all characters in a string:

<script type="text/vbscript">

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

</script>

The above example output results:

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

Try it out . . .

VBScript Asc function Complete VBScript reference manual