I have this structure:
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
I will do a query to database and add structure strcMyInfo to arrDirectory. The arrDirectory will hold data which contains the strcMyInfo data let's say 10 index. For example, the value of arrDirectory.Item(6).strdirname is G2000. How can I loop through the arraylist to find the value of G2000 together with strdirno, strdirdetails,strcategory,strwebsite and strphoneno?
I have search for internet but they only look for a 1 value when adding as example below:
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")
But my code will be like this:
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
Below are code to find the string but it stop there because i don't know how to continue:
Private Sub GetMyDetails(ByVal strLabel As Label)
Dim obj As Object
Try
If strLabel.Content <> 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
If someone know how to use the indexof in arraylist, please guide me. Thanks
ArrayListclass at all. Use aList(Of DISPLAYDIRECTORY)instead.