怎样在程序里使得不往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什么都没加进去
这个错误我找了几天,原来还以为是数据库那段代码的问题
...全文
43 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lvlay 2003-10-23
  • 打赏
  • 举报
回复
搞定拉
goldencity 2003-10-20
  • 打赏
  • 举报
回复
select * from tablename group by [...]
在数据集上作点文章!

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧