Delphi Frage

08/27/2011 17:26 ms​#16
Quote:
Originally Posted by sLay. View Post
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
    if checkbox1.visible = false and checkbox2.visible = false and
       checkbox3.visible = false and checkbox4.visible = false and
       checkbox5.Visible = false and checkbox6.visible = true and
       checkbox7.visible = false and checkbox8.visible = false and
       checkbox9.visible = false then
    [COLOR="Red"][B]begin[/B][/COLOR]
        label1.visible:=false;
        label2.caption:='Du hast das Rätsel gelöst !';
    [COLOR="Red"][B]end;[/B][/COLOR]
end;
Versuchs mal so.
08/27/2011 17:33 KnusperToast#17
ich versteh aber dein Rätsel nicht, weil wenn was unsichtbar ist, kannste auch es nicht mehr anklicken. Oder meinste wenn nur die Checkbox 6 gecheckt ist, dann soll das Label kommen?
08/27/2011 17:36 link#18
Jop, erst mal Syntax lernen.

Code:
if x then
  einzelner_befehl;

if x then
begin
  mehrere;
  befehle;
end
else
  einzelner_befehl;

if x then
  einzelner_befehl
else
begin
  mehrere;
  befehle;
end;
08/27/2011 17:41 link#19
Code:
    if (checkbox1.visible = false) and (checkbox2.visible = false) and
       (checkbox3.visible = false) and (checkbox4.visible = false) and
       (checkbox5.Visible = false) and (checkbox6.visible = true ) and
       (checkbox7.visible = false) and (checkbox8.visible = false) and
       (checkbox9.visible = false) then
    begin
        label1.visible := false;
        label2.caption := 'Du hast das Rätsel gelöst !';
    end;
08/27/2011 17:42 ms​#20
Quote:
Originally Posted by sLay. View Post
Geht leider auch nicht , ich kann direkt auf Ich habs gelöst drücken und dann steht da auch direkt das das Rätsel gelöst wurde.
Glaub ich nicht. :F
08/27/2011 17:43 sLay.#21
DANKE ! Es geht.
Wirklich vielen Dank link :)
Thread kann geschlossen werden :))

Quote:
if (checkbox1.visible = false) and (checkbox2.visible = false) and
(checkbox3.visible = false) and (checkbox4.visible = false) and
(checkbox5.Visible = false) and (checkbox6.visible = true ) and
(checkbox7.visible = false) and (checkbox8.visible = false) and
(checkbox9.visible = false) then
begin
label1.visible := false;
label2.caption := 'Du hast das Rätsel gelöst !';
end;
ist richtig.
08/27/2011 17:47 ms​#22
Wenn das wirklich so ist, dann sehe ich den Sinn dahinter nicht, warum Delphi dem logischen And eine höhere Präzedenz als dem Gleichheitsoperator gegeben hat. ;O
08/27/2011 17:48 KnusperToast#23
Wieso machste es nicht einfach so und löschst das mit visible:

[procedure TForm1.Button1Click(Sender: TObject);
begin
if (checkbox1.unchecked) and (checkbox2.unchecked) and
(checkbox3.unchecked) and (checkbox4.unchecked) and
(checkbox5.unchecked) and (checkbox6.checked) and
(checkbox7.unchecked) and (checkbox8.unchecked) and
(checkbox9.unchecked) then
begin
label1.visible:=false;
label2.caption:='Du hast das Rätsel gelöst !';
end
end;

Wichtig : nach end in der If abfrage kein Semikolon!
08/27/2011 17:59 sLay.#24
Quote:
Originally Posted by Metin2Spieler97 View Post
Wenn das wirklich so ist, dann sehe ich den Sinn dahinter nicht, warum Delphi dem logischen And eine höhere Präzedenz als dem Gleichheitsoperator gegeben hat. ;O
Es ist wirklich so.

_________________

Danke an alle , kann nun geclosed werden.
08/27/2011 18:24 link#25
and ist in Delphi auch ein binärer Operator und
if ($FF = $F0 and $F) and (a = b) then
ist 1. leichter lesbar und 2. lässt sich das logische and besser parsen als bei
if $FF = ($F0 and $F) and a = b then