Hallo,
wie muss ich den folgenden Code ändern, damit anstatt Memo1 List2 da steht?
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:
| var Form1: TForm1; List, List2: TStringlist; implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var a,b,Zahl: integer; Disc: boolean; begin randomize; List := TStringlist.Create; List2 :) TStringlist.Create;
for a := 1 to 32 do begin List.Add(inttostr(a)); end;
while memo1.Lines.Count < 8 do begin Zahl := random(32); for b := 1 to memo1.Lines.Count do begin if inttostr(Zahl) = Memo1.Lines[b] then Disc := False; end; if Disc = true then Memo1.Lines.Add(IntToStr(Zahl)); Disc := true; end; end; end. |
Ich habs schon selbst probiert, aber dann kommen bei mir die Zahlen manchmal doppelt vor.
Sinn des ganzen ist, dass 8 verschiedene Zahlen aus List ausgesucht werden und in List 2 geschrieben werden.
Gruß
Spurius