Todd MacPherson
asked on
Need help fixing my code for detecting duplicates in my listview
I have a listview called lvStands. I need to have code that makes lblDup.visible = true when a duplicate item is found in the listview.
No errors are thrown but it does not find the duplicates either.
PBLack
Public Sub dupStands()
Dim x As Integer
Dim y As Integer
Dim boolDup As Boolean
Dim diff As Integer = 0
Dim lvArray As New ArrayList()
' Search in the listview
For x = 0 To (lvStands.Items.Count - 1)
boolDup = False
' Search in the array
For y = 0 To (lvArray.Count - 1)
If lvStands.Items(x - diff).Text = lvArray.Item(y) Then
boolDup = True
Exit For
End If
Next
If booDup = True Then
lblDup.Visible = True
Else
lblDup.Visible = False
End If
Next
End Sub
No errors are thrown but it does not find the duplicates either.
PBLack
Public Sub dupStands()
Dim x As Integer
Dim y As Integer
Dim boolDup As Boolean
Dim diff As Integer = 0
Dim lvArray As New ArrayList()
' Search in the listview
For x = 0 To (lvStands.Items.Count - 1)
boolDup = False
' Search in the array
For y = 0 To (lvArray.Count - 1)
If lvStands.Items(x - diff).Text = lvArray.Item(y) Then
boolDup = True
Exit For
End If
Next
If booDup = True Then
lblDup.Visible = True
Else
lblDup.Visible = False
End If
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect
thanks
thanks
I think the following might suit:
Open in new window