Jump to content
Sign in to follow this  

Array search in rows

Recommended Posts


With _arraysearch you can only search in columns, see example from helptext.

Is it possible to search in rows?

For example how do i find value 3 in row 3?





Local $avArray[6][2] = [ _

["String0", "SubString0"], _

["String1", "SubString1"], _

["String2", "SubString2"], _

["String3", "SubString3"], _

["String4", "SubString4"], _

["String5", "SubString5"]]

_ArrayDisplay($avArray, "$avArray")

$sSearch = InputBox("_ArraySearch() demo", "String to find?")

If @error Then Exit

$sColumn = InputBox("_ArraySearch() demo", "Column to search?")

If @error Then Exit

$sColumn = Int($sColumn)

$iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, $sColumn)

If @error Then

MsgBox(0, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')


MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')


My scripts: _ConsoleWriteLog | _FileArray2D




Share this post

Link to post
Share on other sites

You are mixed up, _ArraySearch is for one dimensional arrays, meaning it only searches rows. You need a search that checks each column in every row.

The next question is, what do you want returned? You will almost have to return a two element array with the row in the first element and the column in the second element.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.