INSTR

Format

number1 = INSTR (string1,string2)

Description

This statement is used to determine if a given substring exists within a string, and if so, the character position at which the substring first appears in the string. String1 is the string to be searched. String2 contains the substring to find within string1. The character position of string2 within string1 is returned in number1. If the string is not found then number1 is set to zero.

Example

A=INSTR("THE QUICK BROWN FOX","QUICK")
After execution of this statement, variable "A" will contain the value 5, which is the offset of the string "QUICK" within the string "THE QUICK BROWN FOX".
    B=INSTR("FOX","HEN")
After the execution of this statement, variable "B" will contain 0, since the string "HEN" is not found within the string "FOX".

See Also

  • LEFT$
  • RIGHT$
  • MID$
  • LEN