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 參考手冊