我想通過檢查兩個其他列表框來清理列表框。德爾福 - 清潔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