Autor Beitrag
Satego
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 29.01.08 20:53 
Habe ein kleines Quiz gemacht, es geht nur nicht, wenn man auf Abruch klickt und dan auf Ja,
das es dan geschlossen wird. Könnt ihr mir bitte helfen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
 showmessage('Hallo, Willkommen zu meinem Quiz!');
repeat
     a:=inputbox ('Quizmaster','Wofür steht die Abkürzung CPU? (Getrennt und erster Buchstabe Großbuchstabe)','');
    close :=application.MessageBox('Beenden?','Ende',4+32);
    If close=6 then begin
       close;
    end;
     If a= 'Central Processing Unit' then begin
     showmessage('Richtig!'); end else
     showmessage('Falsch!');
  until a='Central Processing Unit' ;


Lg

_________________
motivierter Anfänger ;)
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Di 29.01.08 21:06 
Hi,
verwende "close" nicht als Variable, sondern benutze dafür z.B. "wahl" o.ä.
Close ist in Delphi "reserviert" und schließt z.B. das Formular!

nicht so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
...
close :=application.MessageBox('Beenden?','Ende',4+32);
If close=6 then
begin
 close;
end;
...


besser so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
...
wahl :=application.MessageBox('Beenden?','Ende',4+32);
If wahl=6 then 
begin
 close;
 Exit;
end;
...


Gruß
Crowbar
Satego Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 29.01.08 21:13 
jap danke, aber jetzt hängt es sich auf
Einloggen, um Attachments anzusehen!
_________________
motivierter Anfänger ;)
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Di 29.01.08 21:18 
Um Deinen Code genauer zu analysieren, solltest Du zumindest die gesamte "Procedure" posten.

Gruß
Crowbar
Satego Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Vista

BeitragVerfasst: Di 29.01.08 21:26 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
 procedure TForm1.startClick(Sender: TObject);
var
a: string;
wahl:integer;
begin

showmessage('Hallo, Willkommen zu meinem Quiz!');
repeat
     a:=inputbox ('Quizmaster','Wofür steht die Abkürzung CPU? (Getrennt und erster Buchstabe Großbuchstabe)','');
    wahl :=application.MessageBox('Beenden?','Ende',4+32);
    If wahl=6 then begin
       close;
    end;
     If a= 'Central Processing Unit' then begin
     showmessage('Richtig!'); end else
     showmessage('Falsch!');
  until a='Central Processing Unit' ;
end;

_________________
motivierter Anfänger ;)
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Di 29.01.08 21:35 
Probiere einmal diesen Weg:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Procedure TForm1.startClick(Sender: TObject);
Var
 wahl : Integer;
 a    : String;

begin
  Showmessage('Hallo, Willkommen zu meinem Quiz!');
  repeat
    a:=InputBox ('Quizmaster','Wofür steht die Abkürzung CPU? (Getrennt und erster Buchstabe Großbuchstabe)','');
    if not (a = '') then    // "a" ist leer, wenn auf "Abbruch" gedrückt wurde oder keine Eingabe erfolgte
     begin
       if (a = 'Central Processing Unit') then Showmessage('Richtig!')
       else
        Showmessage('Falsch!');
     end;
    wahl:=Application.MessageBox('Beenden?','Ende',4+32);
   until (a ='Central Processing Unit') or (wahl = 6) ;
end;


Crowbar
Blawen
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 616
Erhaltene Danke: 33

Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
BeitragVerfasst: Di 29.01.08 23:29 
Eine kleine (Rand-) Bemerkung hätte ich noch.

Deine Vorgehensweise ist nicht optimal. Zumindest würde ich die Fragen und Antworten "auslagern" --> z.B. in eine ext. Datei, Datenbank,...

_________________
Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro ;-)