Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi if Klausel: Wort für "aktiv"? (https://www.delphipraxis.net/125129-if-klausel-wort-fuer-aktiv.html)

nixalsverdruss 1. Dez 2008 09:11


if Klausel: Wort für "aktiv"?
 
Hallo an alle,
ich hab ein Problem: Wie heißt das Wort für "aktiv" in einer if then Klausel? Also wenn der Radiobutton aktiv ist (angeklickt ist) soll nach einem Klick auf einen Button das un das passieren...
Sollte auch per "and" funktionieren, also in ner RadioGroupbox.
danke schon ma für eure Bemühungen
nixalsverdruss

Klaus01 1. Dez 2008 09:13

Re: if Klausel: Wort für "aktiv"?
 
RadioButton.checked

Grüße
Klaus

nixalsverdruss 1. Dez 2008 09:14

Re: if Klausel: Wort für "aktiv"?
 
Vielen Dank! süper! :lol:

Michael Habbe 1. Dez 2008 09:20

Re: if Klausel: Wort für "aktiv"?
 
Hi.

Wie Klaus schon schreibt für den einzelnen RadioButton "checked".

Willst Du ein RadioGroup abfragen, löst Du das am Besten mit Case, da Du den selektierten Eintrag über "ItemIndex" ermittelst:

Delphi-Quellcode:
case RadioGroup1.ItemIndex of
  -1: ShowMessage('Nichts markiert');
   0: Tuwas;
   1: Tuwas;
end;
Geht natürlich auch mit if, ist aber etwas mehr Schreibarbeit:

Delphi-Quellcode:
if RadioGroup1.ItemIndex = -1 then
  ShowMessage('Nichts markiert')
else
  if RadioGroup1.ItemIndex = 0 then
    Tuwas
  else
    if RadioGroup1.ItemIndex = 1 then
      Tuwas
    else
      Tuwas;
Gruß
Michael

nixalsverdruss 1. Dez 2008 13:47

Re: if Klausel: Wort für "aktiv"?
 
Danke an Michael,
so funktionierts besser...

nixalsverdruss 1. Dez 2008 13:56

Re: if Klausel: Wort für "aktiv"?
 
Hey,
ich hab noch ein Problem zu if-Klauseln: Wie schreibe ich: "wenn das und das nicht im Editfeld eingetragen wurde, dann das und das machen"? Also wenn etwas richtig eingetragen wurde passiert etwas. Das habe ich so gelöst:

Delphi-Quellcode:
procedure TForm15.Button1Click(Sender: TObject);
begin
if (edit1.Text= 'Grotvadder') and (edit2.Text= 'lääwt') then Form16.Show;
if (edit1.Text= 'Grotvadder') and (edit2.Text= 'lääwt') then close;
Danke schon mal im Voraus
nixalsverdruss

Klaus01 1. Dez 2008 13:58

Re: if Klausel: Wort für "aktiv"?
 
Zitat:

Zitat von nixalsverdruss
Hey,
ich hab noch ein Problem zu if-Klauseln: Wie schreibe ich: "wenn das und das nicht im Editfeld eingetragen wurde, dann das und das machen"? Also wenn etwas richtig eingetragen wurde passiert etwas. Das habe ich so gelöst:

Delphi-Quellcode:
procedure TForm15.Button1Click(Sender: TObject);
begin
if (edit1.Text= 'Grotvadder') and (edit2.Text= 'lääwt') then Form16.Show;
if (edit1.Text= 'Grotvadder') and (edit2.Text= 'lääwt') then close;
Danke schon mal im Voraus
nixalsverdruss

Delphi-Quellcode:
procedure TForm15.Button1Click(Sender: TObject);
begin
if (edit1.Text= 'Grotvadder') and not (edit2.Text= 'lääwt') then Form16.Show;
if (edit1.Text= 'Grotvadder') and not (edit2.Text= 'lääwt') then close;
oder

Delphi-Quellcode:
procedure TForm15.Button1Click(Sender: TObject);
begin
if (edit1.Text= 'Grotvadder') and (edit2.Text <> 'lääwt') then Form16.Show;
if (edit1.Text= 'Grotvadder') and (edit2.Text <> 'lääwt') then close;
Grüße
Klaus

DeddyH 1. Dez 2008 14:00

Re: if Klausel: Wort für "aktiv"?
 
Das würde ich mal ändern:
Delphi-Quellcode:
procedure TForm15.Button1Click(Sender: TObject);
begin
if (edit1.Text= 'Grotvadder') and (edit2.Text= 'lääwt') then
  begin
    Form16.Show;
    close;
  end;
Und das Gegenteil wäre dann:
Delphi-Quellcode:
if (edit1.Text <> 'Grotvadder') or (edit2.Text <> 'lääwt') then

nixalsverdruss 1. Dez 2008 14:01

Re: if Klausel: Wort für "aktiv"?
 
Dankeschön...das hab ich gesucht! :lol:

nixalsverdruss 3. Dez 2008 16:01

Re: if Klausel: Wort für "aktiv"?
 
Ich hab das jetzt so gemacht, aber er zeigt in der "end." Zeile rot an, dass sie falsch wäre. Hier der Delphicode:
Delphi-Quellcode:
procedure TForm19.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
  -1: ShowMessage('Nichts markiert');
   0: Label3.Caption:='Dat is nich richtig! Versöch nochmal!';
   1: Label3.Caption:='Dat is richtig!';
   2: Label3.Caption:='Dat is nich richtig! Versöch nochmal!';
   3: Label3.Caption:='Dat is nich richtig! Versöch nochmal!';
   4: Label3.Caption:='Dat is nich richtig! Versöch nochmal!';
end;

end.
Was ist daran falsch?
Danke schon mal im Voraus
nixalsverdruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:21 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz