VBScript Left 函數
完整的 VBScript 參考手冊
Left 函數從字符串的左側返回指定數量的字符。
提示:請使用 Len 函數來確定字符串中的字符數量。
提示:請參閱 Right 函數。
語法
參數 | 描述 |
string | 必需。從其中返回字符的字符串。 |
length | 必需。規定需返回多少字符。如果設置為 0,則返回空字符串("")。如果設置為大于或等于字符串的長度,則返回整個字符串。 |
實例
實例 1
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Left(txt,15))
</script>
以上實例輸出結果:
This is a beaut
嘗試一下 ? 實例 2
返回整個字符串:
<script type="text/vbscript">
txt="This is a beautiful day!"
x=Len(txt)
document.write(Left(txt,x))
</script>
以上實例輸出結果:
This is a beautiful day!
嘗試一下 ?
完整的 VBScript 參考手冊