unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure vycistit;
procedure formcreate(sender:tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
fsoucet: double;
implementation
{$R *.dfm}
procedure TForm1.Vycistit;
begin
edit1.text:='';
edit2.text:='';
edit3.text:='';
listbox1.items.clear;
Fsoucet:=0;
end;
procedure tform1.formcreate(sender:tobject);
begin
vycistit;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var zadanecislo: double;
begin
if key =#13 then begin edit1.selectall;
begin
try
zadanecislo:=strtofloat(edit1.text);
except showmessage('Špatně zadané číslo');
edit1.setfocus;
edit1.selectall;
exit;
end;
begin
ListBox1.Items.Add(Edit1.Text);
end;
FSoucet:=FSoucet+ZadaneCislo;
begin
edit3.text:=inttostr (ListBox1.Items.Count);
end;
begin
Edit2.Text:=FloatTostr(Fsoucet/ListBox1.Items.Count);
end;
end;
end;
end;
end.