Latest web development tutorials

VBScriptのAsc関数

VBScriptのリファレンス 完全なVBScriptのリファレンス

文字列の最初の文字には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("W") & "<br />")
document.write(Asc("W3CSchool.com"))

</script>

上記の出力の例:

87
87

»をお試しください

例3

どのようにANSIコード内のすべての文字列を返すように:

<script type="text/vbscript">

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

</script>

上記の出力の例:

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

»をお試しください

VBScriptのリファレンス 完全なVBScriptのリファレンス