Autor Beitrag
Paulchengb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 39



BeitragVerfasst: Fr 26.05.06 16:02 
Hi,
ich hab gerade mit Delphi angefangen und jetzt hänge ich das erste mal richtig bei einem Problem fest. Ich hab mit ca. 5 EditFelder gemacht, bei denen ich den Inhalt (sind Zahlen) beim Beenden des Programms speichern will und beim Start sollten sie automatisch geladen werden. Das Speichern geht, nur laden will er sie nicht.

Hier mal der Quellcode. Ich hoffe, es kann mir jmd. helfen.


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:
...

var  List: TStrings;
....

// Speichern

  List := TStringList.Create;
try
  List.Add(labelededit4.Text);
  List.Add(labelededit5.Text);
  List.Add(labelededit6.Text);
  List.Add(labelededit7.Text);
  List.Add(labelededit8.Text);
  List.SaveToFile('C:\Datei.txt');
finally
  List.Free;
end;

// Laden

List := TStringList.Create;
try
  List.LoadFromFile('C:\Datei.txt');
  if List.Count>0 then
    labelededit4.Text:=List[0];
finally
  List.Free;
end;
end;
end.


Moderiert von user profile iconraziel: Quote- durch Delphi-Tags ersetzt
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Fr 26.05.06 16:20 
Hallo
Also was klappt denn nicht ?
Beschreib mal deinen Fehler.
Edit: In welcher Procedure Steht denn dein 'Laden' Abschnitt ?
Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
Paulchengb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 39



BeitragVerfasst: Fr 26.05.06 16:38 
Fehler gibt's in dem Sinn keinen. Er lädt einfach beim Starten nicht den Inhalt, der vorher gespeichert wurde, ein.

Das Laden steht im gleichen procedure wie speichern. Daran könnte es wohl liegen :D

Edit: Ha, ich habs geschafft. Kaum tut man das Laden wo anders hin, lädt er automatisch, wenn ich ein Feld editiere. Kann ich das auch machen, dass er das automatisch beim Programmstart macht?


Zuletzt bearbeitet von Paulchengb am Fr 26.05.06 16:48, insgesamt 1-mal bearbeitet
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Fr 26.05.06 16:42 
Schreib mal den 'Laden' Teil in die FormCreate Procedure.
Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
Paulchengb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 39



BeitragVerfasst: Fr 26.05.06 16:52 
Hi,
hab kein FormCreate.

Aber schau bitte 2 Posts weiter oben in mein Edit.
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Fr 26.05.06 16:59 
Sag ich doch
Doppelklick mal auf dein Formular dann erstellt delphi automatisch eine OnCreate Procedure wenn du da den Code reinpackst läd er den beim start, wenn die Datei C:\Datei.txt Vorhanden ist,automatisch. Ansonsten gibts ne Fehlermeldung :lol:
Gruß

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
Paulchengb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 39



BeitragVerfasst: Fr 26.05.06 17:13 
danke, geht :D