XK8ER
asked on
error on code
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
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)
Do
>> 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
DoEvents
Loop
ASKER
now with your code I get an error in the first strTemp = lvwMain.ListItems.Item(int Cnt).SubIt ems
try change:
strTemp = lvwMain.ListItems.Item(int Cnt).SubIt em(1)
to:
strTemp = lvwMain.ListItems.Item(int Cnt).SubIt ems(1)
strTemp = lvwMain.ListItems.Item(int
to:
strTemp = lvwMain.ListItems.Item(int
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this is what I have so far.. and it works pefectly fine with about 500 records then when I import 4k I get an error in the >> marked line
Private Sub RemoveDups(strNum As Integer)
Dim lRet As ListItem, strTemp As String, intCnt As Long
intCnt = 1
Do While intCnt <= lvwMain.ListItems.Count
strTemp = lvwMain.ListItems.Item(intCnt).SubItems(strNum)
Do
>> lvwMain.ListItems.Item(intCnt).SubItems(strNum) = ""
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).SubItems(strNum) = strTemp
intCnt = intCnt + 1
DoEvents
Loop
End Sub
>>and it works pefectly fine with about 500 records then when I import 4k I get an error in the >> marked line
so what is the value of "strNum" here?
so what is the value of "strNum" here?
ASKER
im using it like this
Call RemoveDups(1)
Call RemoveDups(1)
seems run fine for me, what error message you get here?
ASKER
this error
run time error 35600
index out of bound
run time error 35600
index out of bound
Check this out on possibly to resolve error "run time error 35600 index out of bound":
http://support.microsoft.com/kb/q167122/
http://support.microsoft.com/kb/q167122/
good afternoon!
yes u will receive that kind of error because, ineteger holds the listcount of the listview and when
you remove the duplicate, the integer still holds the initial listcount..
that is why i add "On error resume next on the code"...
I''ve pasted this code earlier on your question, unfornatunately you accepted another comments..lol..
anyway try this code...
On Error Resume Next
Dim lRet As ListItem, strTemp As String, intCnt As Integer
intCnt = 0
Do While intCnt <= lsvWork.ListItems.Count - 1
intCnt = intCnt + 1
strTemp = lsvWork.ListItems.Item(int Cnt).SubIt ems(1)
Do
Set lRet = lsvWork.FindItem(strTemp, lvwSubItem, intCnt + 1, 0)
If Not lRet Is Nothing Then
lsvWork.ListItems.Remove (lRet.Index)
End If
Loop While Not lRet Is Nothing
DoEvents
Loop
i tried it and it works fine with me..
game-master
yes u will receive that kind of error because, ineteger holds the listcount of the listview and when
you remove the duplicate, the integer still holds the initial listcount..
that is why i add "On error resume next on the code"...
I''ve pasted this code earlier on your question, unfornatunately you accepted another comments..lol..
anyway try this code...
On Error Resume Next
Dim lRet As ListItem, strTemp As String, intCnt As Integer
intCnt = 0
Do While intCnt <= lsvWork.ListItems.Count - 1
intCnt = intCnt + 1
strTemp = lsvWork.ListItems.Item(int
Do
Set lRet = lsvWork.FindItem(strTemp, lvwSubItem, intCnt + 1, 0)
If Not lRet Is Nothing Then
lsvWork.ListItems.Remove (lRet.Index)
End If
Loop While Not lRet Is Nothing
DoEvents
Loop
i tried it and it works fine with me..
game-master
Open in new window