String.IndexOf

Syntax

IndexOf(Value: String; [StartIndex: Integer = 0;] [Count: Integer = -1]): Integer;

Parameters

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.

Description

The IndexOf method returns the index of the first occurrence of the substring passed in the Value parameter in the current string.

Comments

If the specified substring is not found in the source string, the method returns -1. Characters are case-sensitive.

Example

Sub UserProc;
Var
    s: String;
Begin
    s := "Prognoz";
    Debug.WriteLine(s.IndexOf("o"));
    Debug.WriteLine(s.IndexOf("o"3));
    Debug.WriteLine(s.IndexOf("o"32));
End Sub UserProc;

After executing the example the development environment console displays the following values:

2

5

-1

See also:

String