dizballanze

Untitled

Nov 14th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.83 KB | None | 0 0
  1. unit Unit3;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes, StdCtrls, SysUtils;
  7.  
  8. type
  9.   Summator = class(TThread)
  10.   private
  11.     { Private declarations }
  12.   protected
  13.     procedure Summ;
  14.     procedure Execute; override;
  15.   public
  16.     listbox_input: TListBox;
  17.     listbox_output: TListBox;
  18.     count: integer;
  19.     sum: integer;
  20.   end;
  21.  
  22. implementation
  23.  
  24. { Summator }
  25.  
  26. procedure Summator.Execute;
  27. begin
  28.  
  29.   count := 1;
  30.  
  31.   while count < 100 do
  32.   begin
  33.     Synchronize(Summ);
  34.   end;
  35.  
  36. end;
  37.  
  38. procedure Summator.Summ;
  39. var
  40.   i: integer;
  41. begin
  42.   if ((listbox_input.Items.Count div 10) >= count) then
  43.     begin
  44.       sum := 0;
  45.       for i:=0 to 9 do
  46.       begin
  47.         sum := sum + StrToInt(listbox_input.Items[(count-1) * 10 + i]);
  48.       end;
  49.       listbox_output.Items.Add(IntToStr(sum));
  50.       count := count + 1;
  51.   end;
  52. end;
  53.  
  54. end.
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment