procedure TForm1.Button1Click(Sender: TObject);
var
i,k:integer;
begin
for i:=0 to 9 do
begin
listbox1.items.add(inttostr(i));
if listbox1.items[i]=inttostr(4) then
k:=i;
end;
Label1.caption:=intToStr(k);
end;procedure TForm1.Button1Click(Sender: TObject);
var
i,k:integer;
begin
for i:=0 to 9 do
begin
listbox1.items.add(inttostr(i));
if listbox1.items[i]='4' then
k:=i;
end;
Label1.caption:=intToStr(k);
end;我的两个测试代码都是4!!!!
var
i,k:integer;
begin
for i:=0 to 9 do
begin
listbox1.items.add(inttostr(i));
if listbox1.items[i]=inttostr(4) then
k:=i;
end;
Label1.caption:=intToStr(k);
end;procedure TForm1.Button1Click(Sender: TObject);
var
i,k:integer;
begin
for i:=0 to 9 do
begin
listbox1.items.add(inttostr(i));
if listbox1.items[i]='4' then
k:=i;
end;
Label1.caption:=intToStr(k);
end;我的两个测试代码都是4!!!!
换成:
if listbox1.item[i]=trim(inttostr(4)) then
i,k:integer;
begin
for i:=0 to 9 do
begin
listbox1.items.add(itntostr(i)); <-----itntostr 错误
if listbox1.item[i]=inttostr(4) then <-----item 错误
k:=i;
end;答案是4
不好意思
我浪费大家的时间了!
谢谢大家!