troubleshooting Question

error on code

Avatar of XK8ER
XK8ERFlag for United States of America asked on
Visual Basic Classic
11 Comments1 Solution187 ViewsLast Modified:
hello there,
when I try to remove duplicates from a listview with more than 3k records in it.. I get an error

run time error 35600
index out of bound

the line bellow with >> is the one that gets yellow
Dim lRet As ListItem, strTemp As String, intCnt As Integer
    intCnt = 0
    Do While intCnt <= lvwMain.ListItems.Count - 1
        intCnt = intCnt + 1
        strTemp = lvwMain.ListItems.Item(intCnt).SubItem(1)
>>          lvwMain.ListItems.Item(intCnt).SubItems(1) = ""          
            Set lRet = lvwMain.FindItem(strTemp, lvwSubitem)
            If Not lRet Is Nothing Then
                lvwMain.ListItems.Remove (lRet.Index)
            End If
        Loop While Not lRet Is Nothing
        lvwMain.ListItems.Item(intCnt).SubItem(1) = strTemp
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros