Einzelnen Beitrag anzeigen

Darlo

Registriert seit: 28. Jul 2008
Ort: München
1.196 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#9

AW: Anweisung erfolderlich, aber Ausdruck vom Typ Beelean?

  Alt 17. Sep 2012, 20:50
Und noch kürzer...

Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var
  Maximum: integer;
  Ausgabe: string;
begin
  Maximum := MaxIntValue([Zahl1, Zahl2, Zahl3]);
  if (Maximum = Zahl1) then
    Ausgabe := '1'
  else if (Maximum = Zahl2) then
    Ausgabe := '2'
  else
    Ausgabe := '3';
  label4.caption := Format('Zahl %s ist die größte Zahl', [Ausgabe]);
end;
So jetzt noch kein if sondern Case

Delphi-Quellcode:
Case MaxIntValue([Zahl1, Zahl2, Zahl3]) of
 Zahl1: Ausgabe := '1';
 Zahl2: Ausgabe := '2';
 Zahl3: Ausgabe := '3';
End;
Aber alle vergessen was ist wenn Zahl 1 z.B.: 5 ist und Zahl 2 und 3 = 100
Philip

Geändert von Darlo (17. Sep 2012 um 20:55 Uhr)
  Mit Zitat antworten Zitat