unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, math;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyEditCount:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i, myneweditcount:integer;
const
NamePrefix = 'Edit';
NewEdits = 3;
begin
myneweditcount:=myeditcount+newedits;
while myeditcount < myneweditcount do begin
TEdit.Create(Self).Name := NamePrefix + IntToStr(myeditcount+1);
with TEdit(FindComponent(NamePrefix + IntToStr(myeditcount+1))) do
begin
Left := 8;
Top := 8 + myeditcount * 32;
Parent := self;
text:='0';
taborder:=myeditcount;
end;
for i:= 1 to 4 do
(Findcomponent('Label' + inttostr(i)) as TLabel).top:=(Findcomponent('Label' + inttostr(i)) as TLabel).top+32;
for i:= 1 to 3 do
(Findcomponent('Button' + inttostr(i)) as TButton).top:=(Findcomponent('Button' + inttostr(i)) as TButton).top+32;
form1.Height:=form1.Height+32;
myeditcount:=myeditcount+1;
end;
edit1.SetFocus;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
myeditcount:=3;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,k,position:integer;
erg:extended;
temp:string;
begin
erg:=0;
for i := 1 to myeditcount do begin
temp:='';
if pos(',',(Findcomponent('Edit' + inttostr(i)) as TEdit).text) <> 0
then begin
position:=pos(',',(Findcomponent('Edit' + inttostr(i)) as TEdit).text);
for k:=1 to position-1 do
temp:=temp+(Findcomponent('Edit' + inttostr(i)) as TEdit).text[k];
temp:=temp+'.';
for k:=position+1 to length((Findcomponent('Edit' + inttostr(i)) as TEdit).text) do
temp:=temp+(Findcomponent('Edit' + inttostr(i)) as TEdit).text[k];
(Findcomponent('Edit' + inttostr(i)) as TEdit).text:=temp;
end;
end;
for i := 1 to myeditcount do
erg:=erg+strtofloat((Findcomponent('Edit' + inttostr(i)) as TEdit).text);
label2.Caption:='Ohne MwSt: ' + floattostr(roundto(erg, -2)) + ' ';
label3.caption:='MwSt: ' + floattostr(roundto(erg*0.16, -2))+ ' ';
label4.Caption:='Incl MwSt: ' + floattostr(roundto(erg*1.16, -2))+ ' ';
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
begin
for i:= 1 to myeditcount do
(Findcomponent('Edit' + inttostr(i)) as TEdit).text:='0';
Label2.caption:='Ohne MwSt:';
Label3.caption:='MwSt:';
label4.caption:='Incl MwSt:';
end;
end.