Autor Beitrag
Bruce86
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 19.03.07 20:59 
ausblenden 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:
procedure TForm1.LoadClick(Sender: TObject);
var
List: TStrings;
begin
List := TStringList.Create;
try
  List.LoadFromFile('C:\Datei.txt');
  if List.Count>0 then
    Edit1.Text:=List[0];
  finally
  List.Free;
end;
end;

procedure TForm1.SaveClick(Sender: TObject);
var
  List: TStrings;
begin
  List := TStringList.Create;
try
  List.Add(Edit1.Text+','+Edit2.Text+','+Edit3.Text+','+Edit4.Text+','+Edit5.Text+','+Edit6.Text+','+Edit7.Text+','+Edit8.Text+','+Edit9.Text+','+Edit10.Text+','+Edit11.Text+','+Edit12.Text+','+Edit13.Text+','+Edit14.Text+','+Edit15.Text+','+Edit16.Text+','+Edit17.Text+','+Edit18.Text+','+Edit19.Text+','+Edit20.Text+','+Edit21.Text+','+Edit22.Text+','+Edit23.Text+','+Edit24.Text+','+Edit25.Text+','+Edit26.Text+','+Edit27.Text+','+Edit28.Text+','+Edit29.Text+','+Edit30.Text+','+Edit31.Text+','+Edit32.Text+','+Edit33.Text+','+Edit34.Text);
  List.SaveToFile('C:\Datei.txt');
finally
  List.Free;
end;
end;


Hi! Habe euch mal den quelltext gepostet in dem sreenshot sehti hr dann auch worum es geht! naja wenn ich die schüler in die editsschreibe speichert er es vernünftig! Jedoch wenn ich lese lädt er es nur ins Edit1 ein!
Denke mal das es daran liegt!
ausblenden Delphi-Quelltext
1:
Edit1.Text:=List[0];					

Wie kann ich es realisieren dass er in das Edit wieder einliest wo es auch vorher gespeichert wurde?

Könntet ihr mir mit nem Quellcode helfen?

Wäre echt super!

Gruß

Bruce86
Einloggen, um Attachments anzusehen!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.03.07 21:03 
Moin und :welcome: im Forum!

Schau dir mal Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT an, damit kommst du weiter! ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 19.03.07 21:05 
schau Dir mal findComponent an und lege Dir ev. eine property an
Bsp
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
property Edits[const AIndex: Integer]: TEdit read GetEdits;

function GetEdits(const AIndex: Integer): TEdit;
begin
  Result := TEdit(FindComponent('Edit'+IntToStr(AIndex)));
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Bruce86 Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 19.03.07 21:51 
hi leute habe es mal mit findcomponent probiert er gibt mir da ne fehlermeldung(s. screenshot)!

Was muss ich verändern?
Einloggen, um Attachments anzusehen!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.03.07 22:02 
Moin!

Wie würdest du denn die Compiler-Fehlermeldung deuten? :roll: ;) Hast du schonmal in die DOH zum Thema FindComponent geschaut? :?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bruce86 Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 19.03.07 22:21 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.LoadClick(Sender: TObject);
var
List: TStrings;
i:integer;
begin
List := TStringList.Create;
try
  List.LoadFromFile('C:\Datei.txt');
  for i := 1 to 34 do
  begin
  with TEdit(FindComponent( 'Edit' + IntToStr( i)) ) do
  begin
  Edit1.Text:=List[0];
  end;
  end;
  finally
  List.Free;
end;
end;


Habe es jetzt so geändert aber der fehler scheint nicht das laden sondern das ausgeben zu sein! in Edit1 schreibt er es 1a aber irgendwie muss das mit Edit1.Text:=List[0]; und vorallem mit
Zitat:
:=List[0];
zu tun haben aber komme da einfach net weiter! habt ihr nen plan? denn wenn ich für die 0 ne 1 schreib bricht er das programm ab
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 19.03.07 22:55 
Hast Du mal in deine Datei geschaut ?
Mit Deinem jetzigen SaveCode hast Du auch bloß eine Zeile in der Datei.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.03.07 23:19 
Moin!

OK, das wird nix, hier mal die Save-Prozedur als Vorlage, Laden darfst du dann nochmal selber probieren: ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.SaveClick(Sender: TObject);
  var
    List: TStringList;
    i: Integer;
begin
  List := TStringList.Create;
  try
    for i := 1 to 34 do
      List.Add(TEdit(FindComponent('Edit'+IntToStr(i))).Text);
    List.SaveToFile('C:\Datei.txt');
  finally
    List.Free;
  end;
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.