unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
ListBox3: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Edit4: TEdit;
ComboBox1: TComboBox;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
ComboBox2: TComboBox;
Label7: TLabel;
Edit5: TEdit;
Edit6: TEdit;
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type TAdr =
record
vorname:
string;
nachname:
string;
alter:
string;
end;
var myadr:
array[0..100]
of TAdr;
gesamt: integer;
anzahl: integer;
procedure TForm1.Button4Click(Sender: TObject);
var addressen: Textfile;
a, i: Integer;
begin
listbox1.Clear;
listbox2.Clear;
listbox3.clear;
AssignFile(addressen, '
addressen.txt');
reset(addressen);
a:=0;
while not eof(addressen)
do
begin
readln(addressen, myadr[a].vorname);
readln(addressen, myadr[a].nachname);
readln(addressen, myadr[a].alter);
Inc(a);
end;
CloseFile(addressen);
anzahl:=a;
gesamt:=Trunc(a*3);
edit5.Text:=IntToStr(anzahl);
edit6.Text:=IntToStr(gesamt);
for i:=0
to anzahl-1
do
begin
listbox1.Items.Add(myadr[i].vorname);
listbox2.Items.Add(myadr[i].nachname);
listbox3.Items.Add(myadr[i].alter);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if edit1.text ='
'
then showmessage('
Bitte einen Vornamen eintragen!');
if edit1.text ='
'
then showmessage('
Bitte einen Nachnamen eintragen!');
if edit1.text ='
'
then showmessage('
Bitte einen Alter eintragen!')
else
begin
myadr[anzahl].vorname:=edit1.Text;
myadr[anzahl].nachname:=edit2.Text;
myadr[anzahl].alter:=edit3.Text;
gesamt:=gesamt+3;
listbox1.Items.Add(myadr[anzahl].vorname);
listbox2.Items.add(myadr[anzahl].nachname);
listbox3.Items.add(myadr[anzahl].alter);
Inc(anzahl);
edit1.text:='
';
edit2.text:='
';
edit3.text:='
';
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var addressen: TextFile;
i: integer;
begin
AssignFile(addressen, '
addressen.txt');
rewrite(addressen);
for i:=0
to anzahl
do
begin
writeln(addressen, myadr[i].vorname);
writeln(addressen, myadr[i].nachname);
writeln(addressen, myadr[i].alter);
end;
CloseFile(addressen);
end;
procedure TForm1.Button2Click(Sender: TObject);
var s:
string;
i, k: integer;
begin
if ComboBox1.ItemIndex=0
then
begin
listbox1.Clear;
listbox2.Clear;
listbox3.clear;
s:=edit4.Text;
k:=0;
for i:=0
to anzahl
do
begin
k:=pos(s, myadr[i].vorname);
if k>0
then
begin
listbox1.Items.Add(myadr[i].vorname);
listbox2.Items.add(myadr[i].nachname);
listbox3.Items.Add(myadr[i].alter);
end
else showmessage (IntToStr(k));
end;
end;
end;
end.