VBScript Right 函數

定義和用法

Right 函數可從字符串右側返回指定數目的字符。

提示:請使用Len 函數來確定字符串中的字符數目。

提示:請參閱 Left 函數。

語法

Right(string,length)
參數 描述
string 必需的。從其中返回字符的字符串。
length 必需的。規定返回多少字符。如果設置為 0,則返回空字符串 ("")。如果設置為大于或等于字符串的長度,則返回整個的字符串。

實例

例子 1

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

輸出:

utiful day!

例子 2

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

輸出:

This is a beautiful day!

例子 3

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

輸出:

This is a beautiful day!