252 of 286
238 StrFind Type Function returning Byte Invocation StrFind(inStr, findStr) StrFind(inStr, findStr, startIdx) StrFind(inStr, findStr, startIdx, ignoreCase) Parameter Method Type Description inStr ByVal String The string to be searched. findStr ByVal String The string being sought. startIdx ByVal integral The index of inStr at which to begin the search. ignoreCase ByVal Boolean A flag controlling whether alphabetic case is significant. Discussion This function attempts to find the first occurrence of the findStr string within the inStr string. If it is found, the return value gives the 1-based index where the sought string was found within the searched string. If the sought string is not found, zero is returned. If the optional startIdx parameter is not given, the search begins at the first character of the searched string, equivalent to specifying 1 for startIdx. If the optional ignoreCase parameter is not given, the search is performed observing alphabetic case differences, otherwise alphabetic case differences are significant or not depending on the value specified for ignoreCase. For the purposes of this parameter only the characters A-Z and a-z (&H41 to &H5a and &H61 to &H7a) are considered to be alphabetic. Searching for a zero length string will always be successful and the return value will be the specified or implied starting index. Searching for a non-zero length string within a zero length string will always fail, returning 0. Examples Dim idx as Byte idx = StrFind("haystack", "needle") ' returns 0 idx = StrFind("haystack with needle", "needle") ' returns 15 idx = StrFind("foo bar foo", "foo", 2) ' returns 9 idx = StrFind("foo bar foo", "", 2) ' returns 2 idx = StrFind("foo bar FOO", "FOO") ' returns 9 idx = StrFind("foo bar FOO", "FOO", 1, true) ' returns 1 Compatibility This function is not available in BasicX compatibility mode. See Also StrCompare