NetWare、Symbian OS、UNIX、Windows、および Windows CE で有効です。
InStr 関数によって、指定されたサブ文字列があるかどうか文字列がスキャンされます。 この関数では、最初にサブ文字列 substr が存在する場所を探して文字列 str がスキャンされます。
関数の形式
Instr(str as String, substr as String) as Integer
検索を実行する対象の文字列を指定します。
検索を実行する対象のサブ文字列を指定します。
この関数によって、substr が始まる str 内の文字位置が返されます。 str に substr がない場合、関数によって 0 が返されます。
例:
以下の例では、InStr 関数を使用して、「Script」が「Unicenter Asset Management Script Interpreter」という文にあるかどうかを判別します。
Dim MyStr as String ' Contains string to evaluate Dim Pos as Integer ' Holds a string index MyStr="Unicenter Asset Management Script Interpreter" Pos=InStr(MyStr,"Script") if Pos>0 then Print "The word ""Script"" was found at character position "+str(Pos)+" in" Print "the sentence """+MyStr+"""." else Print "The word ""Script"" was NOT found in" Print "the sentence """+MyStr+"""." End if
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|