Autor Beitrag
TobiHH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28

XP Pro und Vista Ultimate
Delphi 7
BeitragVerfasst: Mo 23.03.09 22:35 
Hallo
Ich hab mal wieder ein kleines Problemchen :cry:

Auf dem Memo Feld soll jeweils die Zählvariable und ein Text 10 mal aufgegeben werden.
So wie ich das gemacht hab, wird nur die 10 und der Text ausgegeben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
VAR Zaehlvariable:integer;
begin
  FOR Zaehlvariable:= 1 TO 10 DO
     Memo1.text:=(IntToStr(Zaehlvariable)+'. Alles wird gut');
end;

end.


Wäre echt klasse, wenn mir jemand helfen könnte.

Gruß


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Mo 23.03.2009 um 21:38


Zuletzt bearbeitet von TobiHH am Mo 23.03.09 23:30, insgesamt 1-mal bearbeitet
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 23.03.09 23:00 
Hallo

klar, du überschreibst ja jedesmal den Text. Du willst den Text hinzufügen
ausblenden Delphi-Quelltext
1:
2:
 
Memo1.lines.add(...);


Gruß Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
TobiHH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28

XP Pro und Vista Ultimate
Delphi 7
BeitragVerfasst: Mo 23.03.09 23:34 
Danke schonmal. :wink:

Wir haben das Thema jetzt in der Schule angefangen und ich blick da nicht so durch.

Die For-To-Do Schleife funktioniert jetzt. :)

Bei der While-Do und der Repead-Until läuft es die ganze Zeit durch. :cry:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button2Click(Sender: TObject);
Var Zaehlvariable:integer;
begin
Zaehlvariable:=1;
  WHILE Zaehlvariable <=10 do
     Memo2.lines.add(IntToStr(Zaehlvariable)+'. Alles wird gut');
     Zaehlvariable:=Zaehlvariable+1;
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button3Click(Sender: TObject);
Var Zaehlvariable, Endwert:integer;
begin
    Endwert:=10;
     Repeat
     Memo3.lines.add(IntToStr(Zaehlvariable)+'. Alles wird gut');
     until Zaehlvariable < Endwert;

end;


Leider verlier ich da im Moment ziemlich schnell den Überblick drüber. :roll:

Wäre echt klasse, wenn jemand nochmal einen Blick drüber werfen könnte.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 24.03.09 00:11 
Bei der While-Schleife fehlt das begin und end, und bei der Repeatschleife die Erhöhung der Zählvariable.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 24.03.09 01:09 
Und bei repeat auch die Initialisierung der Variable Zaehlvariable.