Autor Beitrag
SLDZ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Do 15.11.07 22:52 
Guten Abend,

ich beschäftige mich nochnicht lange mit Delphi deshalb will ich mich gleich dafür entschuldigen, falls die Frage doof is :P

Ich habe folgenden Code für meinen Button:

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:
var
  Form1: TForm1;
  Saetze: array[0..29of String;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  randomize;
  Saetze[0] := 'Satz 1';
  Saetze[1] := 'Satz 2';
  Saetze[2] := 'Satz 3';
  Saetze[3] := 'Satz 4';
  Saetze[4] := 'Satz 5';
  Saetze[5] := 'Satz 6';
  Saetze[6] := 'Satz 7';
  Saetze[7] := 'Satz 8';
  Saetze[8] := 'Satz 9';
  Saetze[9] := 'Satz 10';
  Saetze[10] := 'Satz 11';
  Saetze[11] := 'Satz 12';
  Saetze[12] := 'Satz 13';
  Saetze[13] := 'Satz 14';
  Saetze[14] := 'Satz 15';
  Saetze[15] := 'Satz 16';
  Saetze[16] := 'Satz 17';
  Saetze[17] := 'Satz 18';
  Saetze[18] := 'Satz 19';
  Saetze[19] := 'Satz 20';
  Saetze[20] := 'Satz 21';
  Saetze[21] := 'Satz 22';
  Saetze[22] := 'Satz 23';
  Saetze[23] := 'Satz 24';
  Saetze[24] := 'Satz 25';
  Saetze[25] := 'Satz 26';
  Saetze[26] := 'Satz 27';
  Saetze[27] := 'Satz 28';
  Saetze[28] := 'Satz 29';
  Saetze[29] := 'Satz 30';
  {         .
            .
            .          }

end;


Ich weiß, was ich machen muss damit ich den Text bei Klick auf einen Button ausgeben kann, ich will aber das der Zufalls Text in einem EditFeld ausgegeben wird.
Kann mir da wer weiterhelfen?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 15.11.07 22:54 
Einfach Edit.Text := '<Text>';

_________________
Markus Kinzler.
SLDZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Do 15.11.07 22:58 
Tut mir leid aber das will nicht klappen, kannst du mir vllt mal ein Beispiel zeigen? :)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 15.11.07 23:02 
ausblenden Delphi-Quelltext
1:
Edit1.Text := Saetze[Random(29];					

_________________
Markus Kinzler.
SLDZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Do 15.11.07 23:05 
Probleme beim Compilieren hab ich mal keine :) Muss ich den Button nicht aber noch irgendwie zu dem Edit Feld zuordnen? Mir wird nämlich kein Zufalls "Satz" ausgegeben...
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Do 15.11.07 23:49 
Warum es nicht klappt kann ich mir grad' nicht erklären, aber'n Tipp für das Füllen deines arrays hätt' ich anzubieten:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject); 
var
i: integer;
begin 
  randomize; // <-- naja,...
  for i := 0 to 29 do
    Saetze[i] := 'Satz ' + inttostr(i+1);
  edit1.text := Saetze[Random(29)]; // <-- wie von mkinzler beschrieben
                                    //     müsste eigentlich gehen
end;


Gruß

Calculon
--
SLDZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Do 15.11.07 23:54 
Danke sehr, hat geklappt. Mein fehler war: Ich habe das "edit1.text := Saetze[Random(29)];" in das EditFeld eingefügt und nicht zum Button -.-
Danke an euch beide ;)