VBScriptのRight関数
Right関数は、文字列の右側から指定された数の文字を返します。
ヒント:文字列の文字数を決定するために、Len関数を使用します。
ヒント:Left関数を参照してください。
文法
Right(string,length)
参数 | 描述 |
---|---|
string | 必需。从其中返回字符的字符串。 |
length | 必需。规定需返回多少字符。如果设置为 0,则返回空字符串("")。如果设置为大于或等于字符串的长度,则返回整个字符串。 |
例
例1
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Right(txt,10))
</script>
txt="This is a beautiful day!"
document.write(Right(txt,10))
</script>
上記の出力の例:
tiful day!
»をお試しください
例2
文字列全体を返します:
<script type="text/vbscript">
txt="This is a beautiful day!"
x=Len(txt)
document.write(Right(txt,x))
</script>
txt="This is a beautiful day!"
x=Len(txt)
document.write(Right(txt,x))
</script>
上記の出力の例:
This is a beautiful day!
»をお試しください
完全なVBScriptのリファレンス