unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Contnrs, ExtCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Label2: TLabel;
label_error: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
n: integer;
EditList: TComponentList;
LabelList: TComponentList;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type TMatrix =
array[1..10, 1..10]
of Real;
var n: integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
EditList:=TComponentList.create;
EditList.OwnsObjects:=true;
LabelList:=TComponentList.create;
LabelList.OwnsObjects:=true;
Width:=368;
Height:=95;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
EditList.Free;
LabelList.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Edit: TEdit;
Label_: TLabel;
i, j: integer;
begin
n:=strtoint(edit1.text);
if (trystrtoint(edit1.Text,n))
and (n>0)
then
begin
if n>10
then
begin
n:=10;
edit1.Text:='
10';
label_error.Caption:='
Matrix ist auf eine Größe von 10,10 limitiert. Eingaben wurden korrigiert.';
end;
Editlist.Clear;
LabelList.Clear;
if n>4
then Width:=25+(n+1)*(57+8);
Height:=110+n*49-8;
for i:=1
to n
do
begin
for j:=1
to n
do
begin
Edit:=TEdit.Create(self);
EditList.Add(Edit);
with Edit
do
begin
Parent:=self;
Left:=16+(j-1)*64;
Top:=72+(i-1)*24;
width:=57;
Name:='
e'+inttostr(j)+inttostr(i);
//text:='';
end;
end;
Edit:=TEdit.Create(self);
EditList.Add(Edit);
with Edit
do
begin
Parent:=self;
Left:=16+(j-1)*64;
Top:=72+(i-1)*24;
width:=57;
Name:='
l'+inttostr(i);
//text:='';
end;
end;
for i:=1
to n
do
begin
Label_:=TLabel.Create(self);
LabelList.Add(Label_);
with Label_
do
begin
Parent:=self;
Left:=16;
Top:=72+n*(27)+(i-1)*(20);
Name:='
label_l'+inttostr(i);
caption:='
v'+inttostr(i)+'
= ';
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label_error.caption:='
';
EditList.Free;
LabelList.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var step, steps: integer;
begin
label_error.Caption:='
';
steps:=n-1;
end;
end.