
delphi编程问题 恳请高手指点
procedureTForm1.Button1Click(Sender:TObject);vari:integer;a:array[1..4]ofreal;b:array...
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
a:array[1..4] of real;
b:array[1..4] of real;
begin
for i := 1 to 4 do
begin
if i=1 then
stringgrid2.Cells[1,i]:= stringgrid1.Cells[1,i]
else if i>1 then
a[i]:= strtofloat(stringgrid1.Cells[1,i]) ;
b[i]:= strtofloat(stringgrid2.Cells[1,i]) ;
stringgrid2.Cells[1,i]:=floattostr(a[i-1]+b[i]);
end;
end; 展开
var
i:integer;
a:array[1..4] of real;
b:array[1..4] of real;
begin
for i := 1 to 4 do
begin
if i=1 then
stringgrid2.Cells[1,i]:= stringgrid1.Cells[1,i]
else if i>1 then
a[i]:= strtofloat(stringgrid1.Cells[1,i]) ;
b[i]:= strtofloat(stringgrid2.Cells[1,i]) ;
stringgrid2.Cells[1,i]:=floattostr(a[i-1]+b[i]);
end;
end; 展开
1个回答
展开全部
什么问题?
stringgrid1.Cells[1,i] 这个控件里面一定要有值才可以!不然会报错
stringgrid1.Cells[1,i] 这个控件里面一定要有值才可以!不然会报错
追问
首先是自己输入数值 点击一个按钮 然后实现stringgrid1中的数据前后相加并赋值到stringgrid2中
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询