VBScript Mid 函數
完整的 VBScript 參考手冊
Mid 函數從字符串中返回指定數量的字符。
提示:請使用 Len 函數來確定字符串中的字符數量。
語法
Mid(string,start[,length])
參數 | 描述 |
string | 必需。從其中返回字符的字符串表達式。 |
start | 必需。規定起始位置。如果設置為大于字符串中的字符數量,則返回空字符串("")。 |
length | 可選。要返回的字符數量。 |
實例
實例 1
返回 1 個字符,從位置 1 開始:
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Mid(txt,1,1))
</script>
以上實例輸出結果:
T
嘗試一下 ? 實例 2
返回 15 個字符,從位置 1 開始:
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Mid(txt,1,15))
</script>
以上實例輸出結果:
This is a beaut
嘗試一下 ? 實例 3
返回所有字符,從位置 1 開始:
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Mid(txt,1))
</script>
以上實例輸出結果:
This is a beautiful day!
嘗試一下 ? 實例 4
返回所有字符,從位置 12 開始:
<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Mid(txt,12))
</script>
以上實例輸出結果:
eautiful day!
嘗試一下 ?
完整的 VBScript 參考手冊