IndexOf(Value: String; [StartIndex: Integer = 0;] [Count: Integer = -1]): Integer;
Value. The substring, which must be searched in the string.
StartIndex. Index of the source string element, with which search should begin. By default, the search starts from the string beginning.
Count. The number of character places, within which the search is executed. By default, the search is executed within the entire string.
The IndexOf method returns the index of the first occurrence of the substring passed in the Value parameter in the current string.
If the specified substring is not found in the source string, the method returns -1. Characters are case-sensitive.
Sub UserProc;
Var
s: String;
Begin
s := "Prognoz";
Debug.WriteLine(s.IndexOf("o"));
Debug.WriteLine(s.IndexOf("o", 3));
Debug.WriteLine(s.IndexOf("o", 3, 2));
End Sub UserProc;
After executing the example the development environment console displays the following values:
2
5
-1
See also: