我想通过检查两个其他列表框来清理列表框。德尔福 - 清洁TListBox物品
- listBox1中会包含项目的大名单
- Listbox2将有句话我想从ListBox 1中删除
- Listbox3必须有存在强制性的话它留在ListBox1的
下面是我迄今为止得到的代码,它对于大型列表非常慢。
// 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;
我不明白你如何在你的代码中使用这两个函数。 什么是你的checknegative函数中的“instring”参数? – LeGEC 2010-04-23 07:29:40
instring是一个字符串。如果单词“鸡”在列表框中,则它返回为真,否则为假。 – Brad 2010-05-08 21:32:30