IndexOf

From NSB App Studio
Revision as of 16:11, 24 July 2019 by Ghenne (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

IndexOf(var, item, fromIndex)

Description

The IndexOf() method returns the position of item in var, starting the search at fromIndex. The variable item can be a string or an array. The result returned starts with 0. If item is not found, -1 is returned.

Example

Find an item:

var a=[1,2,3,4,5];
NSB.Print( a.indexOf(3) )
NSB.Print( "abcde".indexOf("c") )
NSB.Print( a.indexOf(9) )

a=[1,2,3,4,5]
Print IndexOf(a,3)
Print IndexOf("abcde","c")
Print IndexOf(a,9)

Output

2
2
-1

Related Items

Array, Dim, InStr