Delphi中怎样比较大小?
我在form中设置了2个stringgrid。我想把第一个stringgrid的数据有条件的导入到第二个stringgrid中,条件是大于某一列的值,运行时,前三列有数据,从这之后stringgrid中就没数据了,代码如下,请大家帮个忙,解决一下。
procedure TForm1.Button5Click(Sender: TObject);
var
i,j,ccount:integer;
begin
ccount:=StringGrid1.ColCount;
for i:=1 to StringGrid1.RowCount do
begin
stringgrid2.Cells[1,i]:=stringgrid1.Cells[1,i];
stringgrid2.Cells[2,i]:=stringgrid1.Cells[2,i];
stringgrid2.Cells[3,i]:=stringgrid1.Cells[3,i];
for j:=4 to ccount-10 do //数据比较多
begin
if stringgrid1.Cells[j,i]>stringgrid1.Cells[ccount-3,i] then //每一个值和倒数第三列的值比较,谁小,取谁
stringgrid2.Cells[j,i]:=stringgrid1.Cells[ccount-3,i] else
stringgrid2.Cells[j,i]:=stringgrid1.Cells[j,i];
end;
end;
showmessage('数据替换成功!')
end;