Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE
The InStr function scans a string for the occurrence of a given substring. The function scans the string str for the first occurrence of the substring substr.
This string manipulation function has the format:
Instr(str as String, substr as String) as Integer
Identifies the string for which a search is being performed.
Identifies the substring for which a search is being performed.
The function returns the character position in str, at which substr begins. If substr does not occur in str, the function returns 0.
Example: InStr function
This example uses the InStr function to determine if the word "Script" is a part of the sentence "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 © 2013 CA.
All rights reserved.
|
|