VBScript Mid 函式
❮ VBScript 參考大全
Mid 函式從字串中返回指定數量的字元。
提示: 使用 Len 函式確定字串中的字元數。
語法
Mid(string,start[,length])
引數 | 描述 |
---|---|
string | 必需。從中返回字元的字串表示式 |
start | 必需。指定起始位置。如果大於字串中的字元數,則返回空字串 ("") |
length | 可選。要返回的字元數 |
示例
示例 1
從位置 1 開始返回 1 個字元
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,1))
%>
上面程式碼的輸出將是
T
顯示示例 »
示例 2
從位置 1 開始返回 15 個字元
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,15))
%>
上面程式碼的輸出將是
This is a beaut
顯示示例 »
示例 3
從位置 1 開始返回所有字元
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1))
%>
上面程式碼的輸出將是
This is a beautiful day!
顯示示例 »
示例 4
從位置 12 開始返回所有字元
<%
txt="This is a beautiful day!"
response.write(Mid(txt,12))
%>
上面程式碼的輸出將是
eautiful day!
顯示示例 »
❮ VBScript 參考大全