Returns the position of a substring in a string.


var = INSTR( start , string , substr )

var = INSTR( string , substr )


Var Numeric variable that will be assigned with the position of the substring in the string. Returns 0 when the substring is not found.
Start An optional numeric parameter that can be assigned with the first position where must be searched in the string. By default (when not used) the whole string is searched starting from position 1.
String The string to search.
Substr The search string.
At the moment INSTR() works only with internal strings.
Support for external strings will be added too.

Difference with QB
No constants can be used for the string and substring.

See also


Dim S As String * 10 , Z as String * 5
Dim bP as Byte
s = "This is a test"
Z = "is"
bP = Instr(s,z) : Print bP 'should print 3
bP = Instr(4,s,z) : Print bP 'should print 6