Private Sub Command1_Click() Dim arList() As String For i = 0 To List1.ListCount - 1 ReDim Preserve arList(i + 1) arList(i) = List1.List(i) Next
For x = 0 To UBound(arList) templist = arList(x) 'MsgBox templist For y = x + 1 To UBound(arList) - 1 If templist = arList(y) Then arList(y) = "" End If Next Next
List1.Clear For u = 0 To UBound(arList) If arList(u) <> "" Then List1.AddItem arList(u) End If Next
End Sub
Private Sub Form_Load() List1.Clear List1.AddItem "ost" List1.AddItem "kaffe" List1.AddItem "mel" List1.AddItem "sukker" List1.AddItem "ost" List1.AddItem "salt" List1.AddItem "kaffe" End Sub
On Error GoTo lol For i = 0 To List1.ListCount - 1 DoEvents List1.ListIndex = i Dim x As String Dim xa As String Dim xaa As String Dim xx As String x = List1.List(i) xx = List1.List(i + 1) 'trims all spaces in a the current item xa = trimtext(x) xaa = trimtext(xx) 'if dupe is found removes it If LCase(xa) = LCase(xaa) Then DoEvents List1.RemoveItem i i = i - 1 End If Next i MsgBox "Done!" Exit Sub lol: MsgBox "Done!" Exit Sub
thewizard >where is the data comming from origianlly? A database or a file? Why is it in the list twice in the first place, shouldnt it be here you should make the alterations?
Har en listbox ikke en funktion der hedder FindString? Så skulle man vel kunne lave noget kode der (som Terry siger)forhindre at der bliver oprettet "tvillingerne". Jeg skal ikke kunne sige om funktionen også findes i VB5/6, men den findes i VB.NET.
I have NO idea what your application is used for so it shard to say what the best solution is. I would NOT use code to try and remove duplicates form th elist, I would remove it from the SOURCE of the problem which COULD BE your SQL statements.
the wizard> Lets just lets get something streight! This was NO threat it was a promise! We are people using our time to help others and I was trying to make it clear that when people use time to help others then they expect the reward (points which cant be used for much at all). I cant see ANY reason why we should wait until YOU have been up to an exam. The sulution works or it doesnt. The fact that you didnt accept my answer doesnt worry me, after all HY did answer first.
the wizard>After people have given answers, WHY is it necessary for them to have to wait 3 weeks until you have been to an exam or whatever? Ias I said the answer works or it doesnt and you could have checked that out LONG before 16th! Anyway, what have we learnt from this? Well when thewizard places a question then dont bother answering. No, that wasnt a threat it was also a promise :o)
Studer lige 2 min psykologi (kom venner vi rotter os sammen).
Omg.. yes yes.. Terry.. stop med at skrive, du bliver sq ikke klogere at høre på.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.