【发布时间】:2010-04-22 12:25:32
【问题描述】:
我想通过对照其他两个列表框检查一个列表框来清理它。
- Listbox1 将有大的项目列表
- Listbox2 会包含我想从 listbox1 中删除的字词
- 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”参数是什么?
-
instring 是一个字符串。如果单词“chicken”在列表框中,则返回 true,否则返回 false。
标签: delphi listbox string delphi-2009