I want to clean a list box by checking it against two other list boxes.
- Listbox1 would have the big list of items
- Listbox2 would have words I want removed from listbox1
- Listbox3 would have mandatory words that have to exist for it to remain in listbox1
Below is the code I've got so far for this, it's VERY slow with large lists.
// not very efficient
Function checknegative ( instring : String; ListBox : TListBox ) : Boolean;
Var
i : Integer;
Begin
For I := listbox.Items.Count - 1 Downto 0 Do
Begin
If ExistWordInString ( instring, listbox.Items.Strings [i],
[soWholeWord, soDown] ) = True
Then
Begin
result := True; //True if in list, False if not.
break;
End
Else
Begin
result := False;
End;
End;
result:=false;
End;
Function ExistWordInString ( aString, aSearchString : String;
aSearchOptions : TStringSearchOptions ) : Boolean;
Var
Size : Integer;
Begin
Size := Length ( aString );
If SearchBuf ( Pchar ( aString ), Size, 0, 0, aSearchString, aSearchOptions ) <> Nil Then
Begin
result := True;
End
Else
Begin
result := False;
End;
End;