在最近的项目开发过程中,由于客户的需要,要对数据库中相同种类的货物进行汇总统计,经过多方面查阅,发现网上这方面的东西缺乏,于是就写了一个过程来实现这一功能。由不足之处请大家多多指正,多谢程序中用到了第三方控件vsflexgrid,过程中变量vsgrid可以换成stringgrid但其中的部分代码要做必要的删除。procedure heji(vsgrid:tvsflexgrid);varcomn_num,heji,kk,ll:integer; //comn_num: vsgrid的列数 heji:保存合计值 kk:保存程序读取的行数之差he:boolean;beginceshi:=vsgrid.Rows-1;he:=false; try for record_flag:=conm to ceshi do begin if he=true then begin //为真则合计出现过 if record_flag<conm then //跳过合计 begin he:=false; continu