Autor Beitrag
Zlatan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Mo 17.01.11 15:44 
Wie bekomme ich es hin, dass z.B. das Programm mir bei jedem start eine andere Frage stellt???
So wie bei eionem Quiz



Bitte antworten :)
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Mo 17.01.11 15:57 
Hallo??????????
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Mo 17.01.11 15:58 
z.B so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.FormCreate(Sender: TObject);
var fragen: array[0..1of string;
begin
 fragen[0]:= 'Warum?';
 fragen[1]:='Weshalb?';
 randomize;
 label1.Caption := fragen[random(2)];
end;

oder kürzer mit der Unit StrUtils:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormCreate(Sender: TObject);
begin
 randomize;
 label1.Caption := randomfrom(['Warum?','Weshalb?']);
end;


Zuletzt bearbeitet von MaxWurzel am Mo 17.01.11 16:11, insgesamt 1-mal bearbeitet

Für diesen Beitrag haben gedankt: Zlatan
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Mo 17.01.11 15:59 
Hi, und Willkommen in der EE :)
Naja, du must halt ein Array of String machen, und in dieses deine Fragen eintragen. Und dann brauchst du eine Zufallszahl (Stichwort: random). Wichtig ist es, dass du den Zufallsgenerator mit randomize initialisierst, weil sonst bei jedem Start die selbe Zahl käme.

//edit was heißt hier Hallo???, üblicherweise sind Schiebeposts erst nach einem Tag hier erlaubt :?

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)

Für diesen Beitrag haben gedankt: Zlatan
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Mo 17.01.11 16:04 
sorry :)
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Mo 17.01.11 16:16 
Ein weiteres Problem habe ich noch:
Wenn ich also nun ein quiz machen möchte und mir das Programm auch immer verschiedene
Fragen stellt, ist das Problem, das die Buttons immer die selbe Caption haben
und meinetwegen immer Antwort1 also Button1 richtig ist. :[
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Mo 17.01.11 16:19 
Das kannst du auch alles mit Arrays machen. Also speichern, welche Antwort richtig ist, und speichern wie die Buttons heißen sollen. Aber das sind noch zwei wichtige Regeln hier im Forum:
1. Doppelposts sind generell (in jedem Forum) nicht gern gesehen. Lieber die letzte Antwort editieren.
2. Nur eine Frage je Thread, also eigentlich solltest du wenn du ne neue Frage hast einen neuen Thread eröffnen

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)

Für diesen Beitrag haben gedankt: Zlatan
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Mo 17.01.11 16:19 
Du könntest du Caption der Buttons ändern, oder die Fragen so formulieren, dass nicht immer die gleiche Antwort richtig ist.
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Mo 17.01.11 16:26 
Danke für alles werde mich demnächsta n die Regeln halten :}