Autor Beitrag
elduchte
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 199

Win 2000, Win XP
Delphi 7
BeitragVerfasst: Mo 23.06.03 12:02 
Hallo,
habe folgendes Problem:
Ich möchte 10 Zufallszahlen erzeugen und diese jeweils in einer Zeile eines Memo-Feldes ablegen bzw anzeigen.

Habe folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
const
     Anzahl = 10;
var
   Zaehler1 : integer;
   Zaehler2 : integer;
   Feld : array[1..Anzahl] of integer;


begin
     Zaehler2 := 0;
     randomize;
     for Zaehler1 := 1 To Anzahl do
        begin
        Feld[Zaehler1] := random(100);
        Memo1.Lines[Zaehler2] := IntToStr(Feld[Zaehler1]);
        inc(Zaehler2);
        end;
end;


Starte ich das Programm, erscheinen nur 2 Zufallszahlen im Memo-Feld. Wo ist denn der Fehler ? Wer kann mir helfen ??

Danke
Andreas
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.06.03 12:39 
Hallo

Zitat:

Memo1.Lines[Zaehler2] := IntToStr(Feld[Zaehler1]);

wenn dein Memo nicht schon 10 Zeilen enthält nimm
ausblenden Delphi-Quelltext
1:
Memo1.Lines.add(IntToStr(Feld[Zaehler1]));					

(Du mußt die Zeilen hinzufügen, du änderst nichtvorhandene Zeilen ab)

Mfg Frank

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

Win 2000, Win XP
Delphi 7
BeitragVerfasst: Mo 23.06.03 13:40 
Ohhhhh man, da hätte ich nun wirklich selber drauf kommen können...

Vielen Dank, aber warum werden die Zahlen denn erst in Zeile 2 des Memos (also oben am Rand des Memos ist eine Zeiel leer) geschrieben?

Danke
Andreas
elduchte Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 199

Win 2000, Win XP
Delphi 7
BeitragVerfasst: Mo 23.06.03 13:50 
Alles klar, hab den Fehler selber gefunden. Vielen Dank für Deine Hilfe