Autor Beitrag
DelphiNoobCoder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Sa 11.11.06 14:31 
Hi ihr ich bräuchte eure Hilfe PLS
Hier mal ein Bild
user defined image
In den Rot makierten bereich soll eine .txt angezeigt werden(Roter bereich is Frame)
Bei den Blauen bereich soll nen Name reingeschrieben werden der in diese .txt kommt wenn man auf OK drückt. Und da wollt ich Fragen ob das geht das für jeden neuen Name eine Zeile also Name reinschreiben und gleich ne zeile weiter runter. Sry für diese Noob Frage wer net wenn ihr nen paar beispiel Codes posten würdet.

MFG Martin


Zuletzt bearbeitet von DelphiNoobCoder am Sa 11.11.06 14:51, insgesamt 1-mal bearbeitet
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 11.11.06 14:40 
Zum Anzeigen der txt Datei nimmst du ein Memo.
Mit Memo.Lines.Add(Edit.Text); kannst du unten den Namen hinzufügen.
Und mit Memo.SaveToFile bzw LoadFromFile kannst dus speichern.
Zu den Befehlen findes du in der Hilfe von deinem Delphi und hier im Forum nochmal nähere Erklärungen.
Außerdem musst du den Titel dieses Thread ändern so das man weis um was es geht. ;)

MfG
zongo-joe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 134

win xp prof
D3, D4, D7
BeitragVerfasst: Sa 11.11.06 14:42 
Also wenn Du eine Liste mit Namen haben und die als .txt abspeichern willst, dann würde ich

- eine TListbox für die Namen nehmen
- ein TEdit für die Namen
- beim ButtonClick zB Listbox.items.add(edit.text)
- wenn Du die Eigenschaft SORTED der Listbox auf TRUE setzt, werden die Namen ausserdem alphabetisch sortiert
- abspeichern kannst Du die Liste beispeilsweise so (ausm Kopf):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var f:textfile;
    i:integer;
begin
  assign(f,NameTextdatei.txt);
  rewrite(f);
  for i:=1 to listbox.items.count do writeln(listbox.items[i-1]);
  closefile(f);
end;


sorry, AFK

... oder wies der coder geschrieben hat, is eigentlich noch einfacher...
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 11.11.06 14:45 
Wie Zongo sagt kannst du statt einem Memo auch eine ListBox nehmen.
Nur würd ich dir Vorschlagen die ListBox mit ListBox1.Items.SaveToFile('Datei.txt'); zu speichern. Das macht eigentlich das gleiche wie der Code den Zongo geschrieben hat ist aber kürzer. ;)
Ob Memo oder ListBox nimmt sich nicht viel, nur kannst du mit einer ListBox die Einträge noch auswählen bzw markieren.

MfG
DelphiNoobCoder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Sa 11.11.06 14:59 
So also ich bin kein schnell Checker hier mal mein QuellCode

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:
unit Unit3;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    Name: TEdit;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    ListBox1: TListBox;
    ListBox2: TListBox;
    Label2: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure ListBox2Click(Sender: TObject);
    procedure NameChange(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure Label1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;

procedure TForm1.Button3Click(Sender: TObject);
begin

end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin

end;

procedure TForm1.ListBox2Click(Sender: TObject);
begin

end;

procedure TForm1.NameChange(Sender: TObject);
begin

end;
procedure TForm1.Label2Click(Sender: TObject);
begin

end;

procedure TForm1.Label1Click(Sender: TObject);
begin

end;

procedure TForm1.Button4Click(Sender: TObject);
begin

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

end;

end.

procedure TForm1.ListBox1Click(Sender: TObject);
begin

end;


procedure TForm1.NameChange(Sender: TObject);
begin

end;


procedure TForm1.Button3Click(Sender: TObject);
begin

end;


Rot: das is das Rot makierte Feld was muss da rein?
Blau: das is das Namens Feld was muss da rein?
Grün: das is das OK fehlt was muss da rein

Echt nochmal Sry bin halt ein sehr Dummes Kind
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 11.11.06 15:10 
Du solltest es wenigstens mal versuchen selber zu machen.
Aber OK.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button3Click(Sender: TObject);
begin
  Listbox.Items.Add(Edit.Text);
  Listbox.Items.SaveToFile('C:\Datei.txt'); //Speichert den Inhalt
end;

So wird der Name zur Listbox hinzugefügt.
Danach wird der Inhalt gleich gespeichert.

Wenn du die txt beim Start des Programms laden willst dann macht du das im OnShow Event deiner Form.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.OnShow(Sender: TObject);
begin
  Listbox.Items.LoadFromFile('C:\Datei.txt');
end;


Ungetested

MfG
DelphiNoobCoder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Sa 11.11.06 15:25 
Doch ich hab es getestet gong aber nicht da kommt das selbe wie jetzt


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button3Click(Sender: TObject);  
begin  
  Listbox1.Items.Add(Edit.Text);  
  Listbox1.Items.SaveToFile('user.txt'); //Speichert den Inhalt  
end; 
[Error] Unit3.pas(41): Undeclared identifier: 'Edit'



ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.OnShow(Sender: TObject);  
begin  
  Listbox1.Items.LoadFromFile('user.txt');  
end;  

[Error] Unit3.pas(33): Undeclared identifier: 'OnShow'
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 11.11.06 15:31 
Ich schätze du bist Anfänger.
Um die Grundlagen von Delphi zu lernen liest du am besten ein Buch. ;)

Das "Edit" musst du natürlich durch den Namen ersetzten den du deinem NamensFeld gegeben hast.

Um eine OnShow Prozedur zu erstellen wählst du deine Form aus und gehst im Objektinspektor auf den Reiter Ereignisse.
Da Doppelklickst du dann in das Feld neben OnShow.

MfG
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: Sa 11.11.06 15:32 
Ein Buch? In Zeiten des Internets liest man das Tutorial von user profile iconChristian S.:
www.christian-stelzm...rials-crashkurs.html

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

Win XP SP1

BeitragVerfasst: Sa 11.11.06 15:38 
ja das hab ich auch getesetet kommt aber nen fehler mit string

[Error] Unit3.pas(48): Incompatible types: 'String' and 'TEdit'

ok wenn das geht less ich des sofort
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 11.11.06 15:40 
Du musst Edit.Text schreiben.
Das .Text dahinter ist wichtig.

MfG
DelphiNoobCoder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Sa 11.11.06 15:45 
LOOL Geil endlich gehts und jetzt lese ich mal