title: VB.NET Find value in arraylist
body: <p>I have this structure:</p>
  
  <pre><code>Public strcMyInfo As DISPLAYDIRECTORY
  Public arrDirectory As ArrayList
  
  Public Structure DISPLAYDIRECTORY
      Dim strdirno As String
      Dim strdirname As String
      Dim strdirdetails As String
      Dim strcategory As String
      Dim strwebsite As String
      Dim strphoneno As String
  End Structure
  </code></pre>
  
  <p>I will do a query to database and add structure <code>strcMyInfo</code> to <code>arrDirectory</code>. The <code>arrDirectory</code> will hold data which contains the <code>strcMyInfo</code> data let's say 10 index. For example, the value of <code>arrDirectory.Item(6).strdirname</code> is G2000. How can I loop through the arraylist to find the value of G2000 together with <code>strdirno, strdirdetails,strcategory,strwebsite and strphoneno</code>?</p>
  
  <p>I have search for internet but they only look for a 1 value when adding as example below:</p>
  
  <pre><code>myAL.Add("the")
  myAL.Add("quick")
  myAL.Add("brown")
  myAL.Add("fox")
  myAL.Add("jumps")
  myAL.Add("over")
  myAL.Add("the")
  myAL.Add("lazy")
  myAL.Add("dog")
  </code></pre>
  
  <p>But my code will be like this:</p>
  
  <pre><code>If (rdr.HasRows()) Then
       arrDirectory = Nothing
       arrDirectory = New ArrayList
       While rdr.Read
            With strcSearchDir
                    If Not IsDBNull("dirno") Then
                              .strdirno = (rdr("dirno"))
                    Else
                              .strdirno = "N/A"
                    End If
                    If Not IsDBNull("dirname") Then
                              .strdirname = (rdr("dirname"))
                    Else
                              .strdirname = "N/A"
                    End If
                    If Not IsDBNull("dirdetails") Then
                              .strdirdetails = (rdr("dirdetails"))
                    Else
                              .strdirdetails = "N/A"
                    End If
                    If Not IsDBNull("category") Then
                              .strcategory = (rdr("category"))
                    Else
                              .strcategory = "N/A"
                    End If
                    If Not IsDBNull("website") Then
                              .strwebsite = (rdr("website"))
                    Else
                              .strwebsite = "N/A"
                    End If
                    If Not IsDBNull("phoneno") Then
                              .strphoneno = (rdr("phoneno"))
                    Else
                              .strphoneno = "N/A"
                    End If
            End With
            arrDirectory.Add(strcSearchDir)
       End While
       Return True
  Else
       Return False
  End If
  </code></pre>
  
  <p>Below are code to find the string but it stop there because i don't know how to continue:</p>
  
  <pre><code>Private Sub GetMyDetails(ByVal strLabel As Label)
          Dim obj As Object
          Try
              If strLabel.Content &lt;&gt; String.Empty Then
                  For Each obj In arrDirectory
                      If arrDirectory.IndexOf(obj) = strLabel.Content Then
  
                      End If
                  Next
              End If
          Catch ex As Exception
  
          End Try
  End Sub
  </code></pre>
  
  <p>If someone know how to use the indexof in arraylist, please guide me. Thanks </p>