I Have A ListBox With 10,000 Items And Many Many Duplicate Items! I Wonna Save It To A File Without Duplicate Items (One Item Instead All Copies!) And I Use This Way:
Function TMain.List_ExistsIn(ListBox_NAme: TListBox; EParameter: String): Integer;
Var
i: Integer;
Begin
EParameter := LowerCase(EParameter);
Result := -1;
For i:=0 To ListBox_Name.Items.Count - 1 Do
If EParameter = Lowercase(ListBox_Name.Items[i]) Then Begin
Result := i;
Break;
End;
End;
I Use Code Above To Detect A Existing Item And Following Procedure To Save It:
Procedure TMain.MakeList(ListBox_Name: TListBox; FileName: String); //================
Var
i: Integer;
Temp_ListBox: TListBox;
Begin
Temp_ListBox := TListBox.Create(Main);
With Temp_ListBox Do Begin
Parent := Main;
Clear;
For i:=0 To ListBox_Name.Count - 1 Do
If Main.List_ExistsIn(Temp_ListBox, ListBox_Name.Items[i]) = -1 Then
Items.Add(ListBox_Name.Items[i]);
Items.SaveToFile(FileName);
Free;
End;
End;
But It Takes A Very Very Long Time To Proceed. Is There Any Better And Fast Way? Thanks.