[SOLVED] ListView column summation lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2022-07-04 09:10 How can I fix the code to sum a column Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button2Click(Sender: TObject);var i: Integer;  item: TListItem;begin  for i := 0 to ListView1.Items.Count do  begin    i:= Item.SubItems[2];   end;end; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button2Click(Sender: TObject);var i: Integer;  item: TListItem;begin  for i := 0 to ListView1.Items.Count -1 do  begin    ListView1.Items[i].SubItems[2];    Form1.Caption := IntToStr(i);  end;end; ---------------------------------------------------------------------- howardpc · 2022-07-04 09:18 In English a petrel is any bird of the genus Procellaria, so named from the observation that with its webbed feet it appears to be able to walk on water (see the story about Peter in the gospel of Matthew 14:29). Can you try an alternative translation engine so we know what you mean by "petrel"? ---------------------------------------------------------------------- Zvoni · 2022-07-04 10:25 Quote from: Pe3s on July 04, 2022, 11:10:02 amHow can I sum columns in a listview. By hand..... ---------------------------------------------------------------------- Pe3s · 2022-07-04 15:47 ---------------------------------------------------------------------- ASerge · 2022-07-04 19:38 Quote from: Pe3s on July 04, 2022, 11:10:02 amHow can I fix the code to sum a column Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.Button1Click(Sender: TObject);var  Item: TListItem;  Sum: SizeInt = 0;begin  for Item in ListView1.Items do    Inc(Sum, Item.SubItems[2].ToInteger);  Caption := Sum.ToString;end; ---------------------------------------------------------------------- Pe3s · 2022-07-05 06:17 What the code that sums up columns with time in hh: nn formatting looks like ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     procedure TForm2.Button1Click(Sender: TObject);    var      Item: TListItem;      Sum: TTime = 0;    begin      for Item in ListView1.Items do        Sum += Item.SubItems[2].ToInteger;      Caption := FormatDateTime('hh:nn', Sum);    end; ---------------------------------------------------------------------- ASerge · 2022-07-05 19:24 Quote from: Pe3s on July 05, 2022, 08:17:55 amWhat the code that sums up columns with time in hh: nn formatting looks like ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  Item: TListItem;  Sum: TDateTime = 0;  Time: TDateTime;begin  for Item in ListView1.Items do    if TryStrToTime(Item.SubItems[2], Time) then      Sum += Time;  Caption := FormatDateTime('hh:nn', Sum);end; ---------------------------------------------------------------------- wp · 2022-07-05 23:01 Since the sum can become larger than a day I'd rather use the square bracket symbol and the fdoInterval option in FormatDateTime: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  Caption := FormatDateTime('[hh]:nn', sum, [fdoInterval]); ---------------------------------------------------------------------- Pe3s · 2022-07-07 17:11 Thank you very much for help