procedure TForm1.Button1Click(Sender: TObject); var i,j,no:integer; sl,slpos:Tstringlist;//生成结果,分别记录修改项目,以及身份证号修改的位置 osfzh,nsfzh:string;//记录新旧新份证号 issfzh:Boolean;//是否身份证号修改了 begin sl:=TStringList.Create; slpos:=TStringList.Create; with tbl do begin Open; no:=tbl.RecordCount; First; for i:=1to no do begin issfzh:=false; sl.clear; slpos.Clear; osfzh:=Trim(FieldByName('sfzh').AsString); nsfzh:= Trim(FieldByName('ysfzh').AsString); if osfzh<>nsfzh then begin issfzh:=true; sl.Add('sfzh'); for j:=1to Length(osfzh) do begin if osfzh[j]<>nsfzh[j] then slpos.add(IntToStr(j)); end; end; if Trim(FieldByName('xm').AsString)<>Trim(FieldByName('yxm').AsString) then begin sl.Add('xm'); end; if Trim(FieldByName('xbdm').AsString)<>Trim(FieldByName('yxbdm').AsString) then begin sl.Add('xbdm'); end; edit; if issfzh then FieldByName('mpos').Value:=slpos.CommaText; FieldByName('mfield').Value:=sl.CommaText; Post; Next; end;//for end; sl.Free; slpos.Free; end;