VBScript Mid関数
定義と使用法
Mid関数は、指定された数の文字をテキストから返します。
ヒント:Len関数を使用して、テキストの文字数を確認してください。
構文
Mid(string,start[,length])
パラメータ | 説明 |
---|---|
string | 必須の。その文字を返すテキスト表現を指定します。テキストに Null が含まれる場合、Null が返されます。 |
start | 必須の。開始位置を指定します。文字数を超える場合、空文字列("")が返されます。 |
length | 任意の。返す文字数。省略された場合や length がテキストの文字数を超える場合、start からテキストの終わりまでの全ての文字が返されます。 |
例
例 1
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1,1))
出力:
T
例 2
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1,11))
出力:
This is a b
例 3
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1))
出力:
素晴らしい一日!
例 4
dim txt txt="This is a beautiful day!" document.write(Mid(txt,10))
出力:
素晴らしい一日!