怎样在程序里使得不往listbox里添加重复值?为什么我的代码不对?
lvlay 2003-10-20 09:20:44 with DataSource1.DataSet do
begin
first;
while not Eof do
begin
tmp:= fields[4].AsString;
if not inlist2(tmp) then
ListBox3.Items.Add(tmp) ;
next;
end;
end;
Function TOKBottomDlg.InList(tmp:string):boolean;
var
i: integer ;
begin
for i:=0 to ListBox1.Items.Count-1 do
begin
if tmp=ListBox1.Items[i] then
begin
result:= true;
break;
end
else
result:=false;
end;
end;
这段代码在winxp,2000下没问题,在98下时,如果在
if not inlist2(tmp) then
处设断点,就没问题,不设就会导致listbox什么都没加进去
这个错误我找了几天,原来还以为是数据库那段代码的问题