我想将listbox中选中的值(无后缀的文件名),作为LoadFromFile()的参数,如下面的程序所示,但是调不通,请帮帮看一下,谢谢procedure TForm1.ListBox1Click(Sender: TObject);
var
aa,bb:tstringlist;
i:integer;
filepath:string;
begin
aa:=tstringlist.Create;
bb:=tstringlist.Create;
filepath:=listbox1.items[listbox1.itemindex]+'.txt'
aa.LoadFromFile(filepath);
for i:=0 to aa.Count-1 do
begin
bb:=SplitString(aa.Strings[i],',');
stringgrid1.Rows[i]:=bb;
end;
aa.Free;
bb.Free;
end;
var
aa,bb:tstringlist;
i:integer;
filepath:string;
begin
aa:=tstringlist.Create;
bb:=tstringlist.Create;
filepath:=listbox1.items[listbox1.itemindex]+'.txt'
aa.LoadFromFile(filepath);
for i:=0 to aa.Count-1 do
begin
bb:=SplitString(aa.Strings[i],',');
stringgrid1.Rows[i]:=bb;
end;
aa.Free;
bb.Free;
end;
aa.LoadFromFile(filepath);出错信息为
[error]missing operator or semicolon
你的这条语句没加分号