VBScript Left 函數(shù)

2022-08-19 10:01 更新

VBScript Left 函數(shù)可以返回字符串最左邊的指定數(shù)量的字符。


VBScript 參考手冊(cè)完整的 VBScript 參考手冊(cè)

Left 函數(shù)從字符串的左側(cè)返回指定數(shù)量的字符。

提示:請(qǐng)使用 Len 函數(shù)來(lái)確定字符串中的字符數(shù)量。

提示:請(qǐng)參閱 Right 函數(shù)。

語(yǔ)法

Left(string,length)

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

實(shí)例

實(shí)例 1

<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Left(txt,15))
</script>

以上實(shí)例輸出結(jié)果:

This is a beaut

嘗試一下 ?

實(shí)例 2

返回整個(gè)字符串:

<script type="text/vbscript">
txt="This is a beautiful day!"
x=Len(txt)
document.write(Left(txt,x))
</script>

以上實(shí)例輸出結(jié)果:

This is a beautiful day!

嘗試一下 ?

VBScript 參考手冊(cè)完整的 VBScript 參考手冊(cè)
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)