Instr()

Find a substring in a string and return its starting position. The function is case sensitive.

Syntax: byte = Instr( [startPos, ]1) Source as string, Find as string )

  • startPos: Starting position in the main string, beginning from left at position 1 (optional)
  • Source: Main character string to search in
  • Find: Substring to find
  • Returns: Position from left, starting with 1. 0 = not found.

Example:

  dim s as string
  dim pos as byte
  s = "Hello World"
  pos = Instr(s,"lo")    ' output: 4
  pos = Instr(s,"world")  ' output: 0 (not found)
1) As of 2013.R1