Funkce InStr

Vrátí pozici řetězce v jiném řetězci.

Funkce Instr vrátí pozici, na které nalezne shodný řetězec. Pokud řetězec nenalezne, vrátí funkce 0.

Syntaxe:


InStr ([Start As Long,] String1 As String, String2 As String[, Compare As Integer]) As Integer

Návratová hodnota:

Integer

Parametry:

Start: Číselný výraz, který označuje pozici v řetězci, kde začíná hledání podřetězce. Pokud tento parametr vynecháte, hledání začne na prvním znaku řetězce. Minimální povolená hodnota je 1. Maximální povolená hodnota je 2 147 483 648.

String1: The string expression being searched.

String2: Řetězec, který chcete najít.

Compare: Optional type of comparison. The value can be 0 or 1. The default value of 1 specifies case-insensitive. The value of 0 specifies case-sensitive.

note

Case-insensitive comparison may use locale specifics, for example, "s" may match "β".


To avoid a run-time error, do not set the Compare parameter if the Start parameter is omitted.

Chybové kódy:

5 Neplatné volání procedury

Příklad:


Sub ExamplePosition
  Const sCalc = "LibreOffice Calc"

  Instr(sCalc, "calc")     ' returns 13
  Instr(String1:=sCalc, String2:="calc", Start:=1)  ' returns 13
  Instr(11, sCalc, "c")     ' returns 13
  Instr(11, sCalc, "c",  1) ' returns 13
  Instr(11, sCalc, "c",  0) ' returns 16
End Sub