Einzelnen Beitrag anzeigen

danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#6

AW: calculating Rows in Table

  Alt 11. Aug 2012, 15:09
Calculate all DBGrid Rows 'Cena' (price).
'Cena' AsString;
The result written to Edit.


Delphi-Quellcode:
function Calculate_(table: TABSTable; Field: string):string;
var
  celkem: string;
  tpRunTotal: string;
begin
  result := '0';
  tpRunTotal := '0,00';
with Table do
begin
  First;
  while not EOF do
  begin
    tpRunTotal := FloatToStr((StrToFloat(tpRunTotal) + (StrToFloat(Table.FieldByName(field).AsString))));
    celkem := FormatFloat('0.00', StrToFloat(tpRunTotal));
    result := celkem;
    Next;
  end;
end;
end;

Example:
dm := TDataModule;
prodej_distributor := TABSTable;
Edit1.Text := Calculate_(dm.prodej_distributor,'Cena');
Daniel
  Mit Zitat antworten Zitat