Autor Beitrag
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.04.07 11:00 
lass das TForm1 vor den edits.text weg -.-

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Do 05.04.07 11:38 
:rofl:
ich habs ganz anders gemacht ;)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
unit Unit1;

interface

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

type
  TAdresse = Record
    Stadt: String[50];
    Postleitzahl: integer;
    Strasse: String[50];
    Hausnummer: Integer;
  end;
  TPerson = Record
    Name: String[50];
    Vorname: String[50];
    Geburtsort: String[50];
    Telefon: Integer;
    Wohnort: TAdresse;
    Geburtsdatum: Integer;
  end;
  TForm1 = class(TForm)
    BTN_Speichern: TButton;
    Edit_Name: TEdit;
    Edit: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Memo1: TMemo;
    BTN_Anzeigen: TButton;
    Label7: TLabel;
    Label8: TLabel;
    BTN_AdressenOeffnen: TButton;
    ListBox1: TListBox;
    procedure Edit_NameChange(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure BTN_AdressenOeffnenClick(Sender: TObject);
    procedure BTN_AnzeigenClick(Sender: TObject);
    procedure BTN_SpeichernClick(Sender: TObject);
  private
    Personen : Array [1..10] of TPerson;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

procedure TForm1.BTN_AdressenOeffnenClick(Sender: TObject);
var
  DateiAdressen: File of TPerson;
  i: integer;
begin
  try
    AssignFile(DateiAdressen,'U:\Adressen.dat');
    Reset(DateiAdressen);
    for I := 1 to 10 do
      Read(DateiAdressen,Personen[i]);
  finally
    CloseFile(DateiAdressen);
  end;
  for I := 1 to 10 do
    ListBox1.Items.Add(InttoStr(i) + ':  ' + Personen[i].Name);
end;



procedure TForm1.Edit_NameChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Name := Edit_Name.text;
  Listbox1.Items[ListBox1.ItemIndex] := InttoStr(i) + ':  ' + Personen[i].Name;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var I: Integer;
begin
 i := Listbox1.ItemIndex + 1;
 Edit_Name.Text := Personen[i].Name;
end;

procedure TForm1.BTN_SpeichernClick(Sender: TObject);
var
  DateiAdressen: File of TPerson;
  i: integer;
begin
  try
    AssignFile(DateiAdressen,'U:\Adressen.dat');
    ReWrite(DateiAdressen);
    for I := 1 to 10 do
    Write(DateiAdressen,Personen[i]);
  finally
    CloseFile(DateiAdressen);
  end;
end;


procedure TForm1.BTN_AnzeigenClick(Sender: TObject);
var i: integer;
begin
  memo1.Clear;
  for I := 1 to 10 do
  begin
    memo1.Lines.add(('Name: ') + (Personen[i].name));
    memo1.Lines.add(('Vorname: ') + (Personen[i].vorname));
    memo1.Lines.add(('PLZ: ') + (IntToStr(Personen[i].Wohnort.Postleitzahl)));
    memo1.Lines.add(('Stadt: ') + (Personen[i].Wohnort.Stadt));
    memo1.Lines.add(('Geburtsort: ') + (Personen[i].Geburtsort));
    memo1.Lines.add(('Geburtsdatum: ') + (IntToStr(Personen[i].Geburtsdatum)));
    memo1.Lines.add(('Strasse: ') + (Personen[i].Wohnort.Strasse));
    memo1.Lines.add(('Hausnummer: ') + (IntToStr(Personen[i].Wohnort.Hausnummer)));
    memo1.Lines.Add('=============================================');
  end;
end;
end.



doll ne? :D

_________________
<(^^<) <(^^)> (>^^)>
===================
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 05.04.07 12:19 
Notfalls schaust Du hier mal nach:
www.jasocul.de/html/...isierte_dateien.html

Im Source sind noch eine ganze Menge Erläuterungen enthalten. Dort wird übrigens komplett ohne Array gearbeitet. Das hat den Vorteil, dass die Änderungen nicht futsch sind, wenn das Programm abstürzt. Und wie gewünscht, arbeitet es mit Records. Du müsstest allerdings den Record und was damit zusammenhängt, an Deine Bedürfnisse anpassen.
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Do 05.04.07 12:30 
8)
das schau ich mir doch gleich mal an :D

_________________
<(^^<) <(^^)> (>^^)>
===================
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 08:44 
Soo..
mein momentaner Status:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
unit Unit1;

interface

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

type
  TAdresse = Record
    Stadt: String[50];
    Postleitzahl: integer;
    Strasse: String[50];
    Hausnummer: Integer;
  end;
  TPerson = Record
    Name: String[50];
    Vorname: String[50];
    Geburtsort: String[50];
    Telefon: Integer;
    Wohnort: TAdresse;
    Geburtsdatum: Integer;
  end;
  TForm1 = class(TForm)
    BTN_Speichern: TButton;
    Edit_Name: TEdit;
    Edit_Vorname: TEdit;
    Edit_Postleitzahl: TEdit;
    Edit_Wohnort: TEdit;
    Edit_Geburtsort: TEdit;
    Edit_Geburtsdatum: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit_Strasse: TEdit;
    Edit_Hausnummer: TEdit;
    Memo1: TMemo;
    BTN_Anzeigen: TButton;
    Label7: TLabel;
    Label8: TLabel;
    BTN_AdressenOeffnen: TButton;
    ListBox1: TListBox;
    procedure Edit_GeburtsdatumChange(Sender: TObject);
    procedure Edit_GeburtsortChange(Sender: TObject);
    procedure Edit_VornameChange(Sender: TObject);
    procedure Edit_PostleitzahlChange(Sender: TObject);
    procedure Edit_WohnortChange(Sender: TObject);
    procedure Edit_StrasseChange(Sender: TObject);
    procedure Edit_HausnummerChange(Sender: TObject);
    procedure Edit_NameChange(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure BTN_AdressenOeffnenClick(Sender: TObject);
    procedure BTN_AnzeigenClick(Sender: TObject);
    procedure BTN_SpeichernClick(Sender: TObject);
  private
    Personen : Array [1..10] of TPerson;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

procedure TForm1.BTN_AdressenOeffnenClick(Sender: TObject);
var
  DateiAdressen: File of TPerson;
  i: integer;
begin
  try
    AssignFile(DateiAdressen,'U:\Adressen.dat');
    Reset(DateiAdressen);
    for I := 1 to 10 do
      Read(DateiAdressen,Personen[i]);
  finally
    CloseFile(DateiAdressen);
  end;
  for I := 1 to 10 do
    ListBox1.Items.Add(InttoStr(i) + ':  ' + Personen[i].Name + ' , ' + Personen[i].Vorname);
  begin
  i := ListBox1.ItemIndex + 1;
  Edit_Name.Text := Personen[i].Name;
  Edit_Vorname.Text := Personen[i].Vorname;
  Edit_Geburtsdatum.Text := IntToStr(Personen[i].Geburtsdatum);
  Edit_Geburtsort.Text := Personen[i].Geburtsort;
  Edit_Wohnort.Text := Personen[i].Wohnort.Stadt;
  Edit_Postleitzahl.Text := IntToStr(Personen[i].Wohnort.Postleitzahl);
  Edit_Strasse.text := Personen[i].Wohnort.Strasse;
  Edit_Hausnummer.Text := IntToStr(Personen[i].Wohnort.Hausnummer);
  end;
end;



procedure TForm1.Edit_GeburtsdatumChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Geburtsdatum := StrToInt(Edit_Geburtsdatum.text);
end;

procedure TForm1.Edit_GeburtsortChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Geburtsort := Edit_Geburtsort.text;
end;

procedure TForm1.Edit_HausnummerChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Wohnort.Hausnummer := StrToInt(Edit_Hausnummer.text);
end;

procedure TForm1.Edit_NameChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Name := Edit_Name.text;
  Listbox1.Items[ListBox1.ItemIndex] := InttoStr(i) + ':  ' + Personen[i].Name + ' , ' + Personen[i].Vorname;
end;

procedure TForm1.Edit_PostleitzahlChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Wohnort.Postleitzahl := StrToInt(Edit_Postleitzahl.text);
end;

procedure TForm1.Edit_StrasseChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Wohnort.Strasse := Edit_Strasse.text;
end;

procedure TForm1.Edit_VornameChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Vorname := Edit_Vorname.text;
end;

procedure TForm1.Edit_WohnortChange(Sender: TObject);
var i: Integer;
begin
  i := ListBox1.ItemIndex + 1;
  Personen[i].Wohnort.Stadt := Edit_Wohnort.text;
end;

procedure TForm1.ListBox1Click(Sender: TObject);                         //Bei dieser Procedure schmeißt er mich 
var I: Integer;                                                          //beim Geburtsdatum wg Zugriffsverletzung
begin
  i := Listbox1.ItemIndex + 1;
  Edit_Name.Text := Personen[i].Name;
  Edit_Vorname.Text := Personen[i].Vorname;
  Edit_Geburtsdatum.Text := IntToStr(Personen[i].Geburtsdatum);
  Edit_Geburtsort.Text := Personen[i].Geburtsort;
  Edit_Wohnort.Text := Personen[i].Wohnort.Stadt;
  Edit_Postleitzahl.Text := IntToStr(Personen[i].Wohnort.Postleitzahl);
  Edit_Strasse.text := Personen[i].Wohnort.Strasse;
  Edit_Hausnummer.Text := IntToStr(Personen[i].Wohnort.Hausnummer);
end;

procedure TForm1.BTN_SpeichernClick(Sender: TObject);
var
  DateiAdressen: File of TPerson;
  i: integer;
begin
  try
    AssignFile(DateiAdressen,'U:\Adressen.dat');
    ReWrite(DateiAdressen);
    for I := 1 to 10 do
    Write(DateiAdressen,Personen[i]);
  finally
    CloseFile(DateiAdressen);
  end;
end;


procedure TForm1.BTN_AnzeigenClick(Sender: TObject);
var i: integer;
begin
  memo1.Clear;
  for I := 1 to 10 do
  begin
    memo1.Lines.add(('Name: ') + (Personen[i].name));
    memo1.Lines.add(('Vorname: ') + (Personen[i].vorname));
    memo1.Lines.add(('PLZ: ') + (IntToStr(Personen[i].Wohnort.Postleitzahl)));
    memo1.Lines.add(('Stadt: ') + (Personen[i].Wohnort.Stadt));
    memo1.Lines.add(('Geburtsort: ') + (Personen[i].Geburtsort));
    memo1.Lines.add(('Geburtsdatum: ') + (IntToStr(Personen[i].Geburtsdatum)));
    memo1.Lines.add(('Strasse: ') + (Personen[i].Wohnort.Strasse));
    memo1.Lines.add(('Hausnummer: ') + (IntToStr(Personen[i].Wohnort.Hausnummer)));
    memo1.Lines.Add('=============================================');
  end;
end;
end.


Sonst sieht es garnicht mal so schlecht aus!
Das Memo feld nehme ich wahrscheinlich ganz raus wenn die ListBox richtig funktioniert!

_________________
<(^^<) <(^^)> (>^^)>
===================
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 10.04.07 08:46 
Na super!
Jetzt kann ich nicht mal alle meine Freunde eintragen, weil ich mehr als 10 hab -.-

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 08:55 
user profile iconZeitGeist87 hat folgendes geschrieben:
Na super!
Jetzt kann ich nicht mal alle meine Freunde eintragen, weil ich mehr als 10 hab -.-


Das möchte ich doch stark bezweifeln :D
und wenn du so weiter machst hast du 1 weniger :P *gg*
Ok ok ich habe den wink mit dem Zaunpfahl verstanden *seufz* ;)

_________________
<(^^<) <(^^)> (>^^)>
===================
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 10.04.07 09:03 
user profile iconFiceGoesDelphi hat folgendes geschrieben:
user profile iconZeitGeist87 hat folgendes geschrieben:
Na super!
Jetzt kann ich nicht mal alle meine Freunde eintragen, weil ich mehr als 10 hab -.-


Das möchte ich doch stark bezweifeln :D
und wenn du so weiter machst hast du 1 weniger :P *gg*
Ok ok ich habe den wink mit dem Zaunpfahl verstanden *seufz* ;)


Du zählst (noch :!: ) nicht dazu. Freunde wohnen entweder in meiner Nähe oder können gut Delphi programmieren :wink:

Aber ich muss dich auch mal loben: Es wird immer besser!

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 09:14 
Danke danke mein Freund .... :roll: :lol:
Naja ich bin noch lange nicht zufrieden!
aber so ein paar aufmunternde Worte sind schon schön!
Trotzdem hänge ich jetzt .. ich weiß nicht genau warum -.- ... irgwie funktioniert jetzt gerade garnichts mehr richtig :(
Einloggen, um Attachments anzusehen!
_________________
<(^^<) <(^^)> (>^^)>
===================
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 10.04.07 09:31 
OnExit weglassen. Erst beim Klick auf Speichern alle Speichern.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 09:34 
thx! bastel ich um!

_________________
<(^^<) <(^^)> (>^^)>
===================
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 10.04.07 09:37 
Wenn I > 10 ist, geht sowieso nix mehr. Außerdem beginnt I bei 0, das Array aber erst bei 1.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
FiceGoesDelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 09:44 
user profile iconGTA-Place hat folgendes geschrieben:
Wenn I > 10 ist, geht sowieso nix mehr. Außerdem beginnt I bei 0, das Array aber erst bei 1.


wo beginnt i bei 0 ?
Habe extra i := 1 gesetzt und ansonsten i := ListBox1.ItemIndex + 1 .. somit dürfte es da doch keine probleme geben oder?! :gruebel:

_________________
<(^^<) <(^^)> (>^^)>
===================
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 10.04.07 09:45 
ListBox.ItemIndex = -1, wenn nichts selektiert ist.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)