Latest web development tutorials

VBScript Right 函數

VBScript 參考手冊 完整的VBScript參考手冊

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>

以上實例輸出結果:

tiful day!

嘗試一下»

實例2

返回整個字符串:

<script type="text/vbscript">

txt="This is a beautiful day!"
x=Len(txt)
document.write(Right(txt,x))

</script>

以上實例輸出結果:

This is a beautiful day!

嘗試一下»

VBScript 參考手冊 完整的VBScript參考手冊