Trying to search arrayList "fields" and return Index

Posted on 2013-10-16
Medium Priority
Last Modified: 2013-10-16
Hi everyone,

I've got an ArrayList that has been populated with objects defined in our business logic, using data returned from a SQL Stored Procedure.  The app I'm working in is developed in VB.NET 2.0 (yes, I know. :) ).

I'm trying to figure out how to search through that ArrayList for a specific substring of characters in one "field" from the objects in the ArrayList, return the index of that item, and then remove it from the ArrayList.  

I was trying something like this:  

        For i As Integer = 0 To oAcc.FundList.Count - 1
            If oAcc.FundList.Item(i).OptionCode.ToString().Substring(0, 2) = "CD" Then
            End If

Open in new window

Where oAcc.FundList() is my ArrayList and OptionCode is one of the fields in the object contained in oAcc.FundList().

The problem I'm getting is that nothing is being returned, and I verified that there should be something returned based on the data from the Stored Procedure.  

Where am I going wrong?  

Changing the datatype of the Object returning the ArrayList is, unfortunately, not an option here.
Question by:Jamie Fellrath
LVL 19

Accepted Solution

Ken Butters earned 2000 total points
ID: 39578017
looks like you are removing items from the list you are traversing.

try going backwards.
        For i As Integer =  oAcc.FundList.Count - 1 to 0 step -1
            If oAcc.FundList.Item(i).OptionCode.ToString().Substring(0, 2) = "CD" Then
            End If

Open in new window


Author Closing Comment

by:Jamie Fellrath
ID: 39578024
Awesome!  Thank you so much, that did the trick exactly!  I think I was staring at this for too darned long!  :)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question