[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

What is the easiest way to find the number of occurances of a particular item in an arraylist?

Posted on 2013-06-14
2
Medium Priority
?
202 Views
Last Modified: 2013-06-17
The title says it all.
0
Comment
Question by:NevSoFly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 2000 total points
ID: 39249495
Two ways to do this. First would be using LINQ. There's a discussion about that at http://www.vbforums.com/showthread.php?674781-Counting-number-of-occurrences-of-element-within-array-or-arraylist

The other way is the manual way is below

Private Function NumberOfInstances(ByVal SearchFor As String, ByVal SearchList As ArrayList) As Integer
        Dim Counter As Integer = 0
        Dim i As Integer
        For i = 0 To SearchList.Count - 1
            If CStr(SearchList(i)) = SearchFor Then
                Counter += 1
            End If
        Next

        Return Counter
    End Function

Open in new window

0
 

Author Closing Comment

by:NevSoFly
ID: 39253045
perfect.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

649 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