Listbox Checker

KummaZ
09-10-2003, 12:13 AM
I have a listbox and I need to check if there are 2 of the same item in it and if there are I need it to delete one of them. I have no idea how to do this. Thanks to whoever can help me

rajeeshun
09-10-2003, 12:39 AM
I have a listbox and I need to check if there are 2 of the same item in it and if there are I need it to delete one of them. I have no idea how to do this. Thanks to whoever can help me


Hi
Try this. This will remove the duplicates


Dim i As Integer
Dim j As Integer
Dim listcount As Integer
Dim stritem As String
Dim searchItem As String

listcount = List1.listcount
i = 0
j = 0

Do While i <= listcount - 1
searchItem = List1.List(i)

Do While j <= List1.listcount - 1
If j = i Then GoTo NextStep
If searchItem = List1.List(j) Then
List1.RemoveItem (j)
End If
NextStep:
j = j + 1
Loop
i = i + 1
j = 0
Loop

KummaZ
09-10-2003, 12:44 AM
works perfect, thanks for that.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum