Forum > LCL
[SOLVED] VST summation time bugs
Pe3s:
Hello how can I fix the code so that it counts the hours correctly from the Virtual String Tree column. E.g. 21x8=168 and the code gives 144
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.SumHour;var Data: PData; Node: PVirtualNode; SUM: TDateTime = 0; Time: TDateTime;begin Node := VST.GetFirst(); while Node <> nil do begin Data := VST.GetNodeData(Node); if TryStrToTime(Data^.iGodzin, Time) then SUM += Time; Node := VST.GetNext(Node); end; Panel2.Caption := 'Hour in month: ' + FormatDateTime('[hh]:nn', SUM, [fdoInterval]) +' h';end;
dseligo:
Maybe there is something wrong with your data?
Try by adding 'else' to 'if TryStrToTime(Data^.iGodzin, Time) then'. Maybe you'll catch something.
Pe3s:
The data is correct if else returns nothing. Any ideas ?
bytebites:
AI chrystall ball is still under construction.
168-144=24 =1 day.
wp:
Wrote a small test application to verify that your code is correct. The issue must be somewhere else in your code.
Navigation
[0] Message Index
[#] Next page