Click to See Complete Forum and Search --> : how do we search arrays in VB.Net?


xeviva
December 2nd, 2002, 08:06 PM
I have been staring at this code for days now and cannot see the solution, I am reading in a text file of products and prices, and placing the items in one array and the prices in another.

I have a combo box full of the products, which is an ordered list, the array version is NOT ordered.

I want to search for the indexNo of the item selected in the combo box, and use that index to get price, as the item and its price are stored in the same position in there respective arrays.

:( Now, VB.net gives me an error msg when I code this in the way I think should work "Overload resolution failed because no accessible 'IndexOf' accepts this number of arguments". My line of code is as follows:

:rolleyes:

Price(product.IndexOf(ComboBox.SelectedItem()))

Help A poor, inocent (rare) woman programmer in distress?

Athley
December 3rd, 2002, 02:11 AM
The different overloaded versions of IndexOf takes no less than 2 argument and you have only one. IndexOf(array, value).... would be something like.....

Price(Array.IndexOf(product, ComboBox.SelectedItem))

/Leyan

xeviva
December 3rd, 2002, 02:04 PM
thanks