Skip to main content

INSTR              ' VB style

Syntax


#include <VBSTRING.bas>                        ' source in /Program Files/Coridium/BASIClib 

FUNCTION INSTR( startsearchee, lookfor )

Description


This FUNCTION written in BASIC searches the string  searchee looking for the string lookfor, starting at the *start-*th character.

If it is found, the position of the first character of lookfor in searchee is returned, otherwise 0.

start is based on 1 being the first character, which is consistent with the InStr VB function, but inconsistent with the VB searchee.Chars(0) being the first character.  The C style STRSTR version of this routine uses 0 as the first character.\

Example

\

#include <VBSTRING.bas>

DIM text(10)

text = "HELLO
WORLD"
PRINT
INSTR(1, text, "LLO") ' will
display 3

\

Differences from other BASICs

\

  • similar function as Visual BASIC
  • no equivalent in PBASIC

See also

\