unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Label1: TLabel;
    procedure ListBox1Click(Sender: TObject);
  private
    s: integer;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ListBox1Click(Sender: TObject);
var i:integer;
begin
  s:=0;
  with ListBox1 do
  for i:=0 to Count-1 do
  if Selected[i] then  //sprawdzenie zaznaczonych elementów
      s:=s+StrtoInt(Items[i]);
  Label1.Caption:=InttoStr(s);  //wyświetlenie sumy na etykiecie
end;

end.
