VBScriptMid関数_
❮完全なVBScriptリファレンス
Mid関数は、文字列から指定された数の文字を返します。
ヒント: Len関数を使用して、文字列の文字数を判別します。
構文
Mid(string,start[,length])
Parameter | Description |
---|---|
string | Required. The string expression from which characters are returned |
start | Required. Specifies the starting position. If set to greater than the number of characters in string, it returns an empty string ("") |
length | Optional. The number of characters to return |
例
例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リファレンス