Autor Beitrag
bruce185
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: So 09.10.05 16:39 
hi,
ich habe ein Problem mit meinem Projekt, und zwar möchte ich das was in Edit1 steht, in Label1 erscheint, und nach 5 Sekunden soll das was in Edit2 steht in Label1 erscheinen, bis Edit6, das kann man doch irgendwie mit einer Schleife machen, oder?, ich mache dann einfach so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := Edit1.Text;
end;


das es in Label1 erscheint, aber wie mache ich das jetzt mit der Schleife, das es die Edits durschläuft bis Edit6, für jede hilfe bin ich euch sehr dankbar, ich danke euch schonmal :)

Andreas
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: So 09.10.05 16:49 
so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=1 to 6 do begin
label1.caption:=findcomponent('edit'+inttostr(i)).text);
sleep(5000); //zeit in millisekunden bis aktualisierung 
end;

wäre aber besser mit nem timer da bei sleep das programm komplett steht. oder nen thread aber das is noch schwerer.
ich würde es nicht mit ner schleife machen sondern timer... aber wenn du in der zeit wo das angezeigt wird nix anderes mit dem prog vorhast geht sleep

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: So 09.10.05 17:52 
vielen dank für deine antwort, ich habe das jetzt in Timer1 hinzugefügt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Timer1Timer(Sender: TObject);
var i: integer;
begin
  for i:=1 to 6 do begin
  Label1.Caption:=FindComponent('Edit'+IntToStr(i)).text);
  sleep(5000); //zeit in millisekunden bis aktualisierung
end;


da kommt aber fehlermeldung:
[Error] Unit1.pas(44): Undeclared identifier: 'text'
[Error] Unit1.pas(48): '.' expected but ';' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

wie muss ich text deklarieren? weil es kommt nur da wo .text steht fehlermeldung, ich danke dir schonmal :)

Andreas
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: So 09.10.05 17:55 
sry
so müsste es gehn (getestet):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
  Form1: TForm1;
  var i:integer = 1;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if i>3 then i:=1;
Label1.Caption:=TEdit(FindComponent('Edit'+IntToStr(i))).text;
inc(i);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;

timerinterval auf 5000.

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: So 09.10.05 18:03 
es funktioniert nicht, .text ist undeklariert, oder falsch hingesetzt, gibt es vieleicht noch eine andere Methode? danke schonmal :(

Andreas
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 09.10.05 18:03 
besser ists mit typecast:
ausblenden Delphi-Quelltext
1:
Label1.Caption:=TEdit(FindComponent('Edit'+IntToStr(i))).text;					

//edit: aha, das hat er stillschweigend geändert :P

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: So 09.10.05 18:05 
habs geändert und getestet. ja hatte das tedit vorher vergessen. is mir dann auch aufgefallen als bruce meinte .text wäre net deklariert hab ichs ma selbst probiert...
edit: bevor ich deinen post gesehn hab retnyg!

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700