Einzelnen Beitrag anzeigen

skatem

Registriert seit: 28. Mai 2012
4 Beiträge
 
#1

Währungsumrechner

  Alt 28. Mai 2012, 13:27
Sorry erstmal, ich wusste nicht, wo ichs sonst hätte reinschreiben sollen.
Naja ich habe mit Lazarus einen mehr oder weniger guten Währungsumrechner zu programmieren und wollte halt am Ende einen Button, mit dem ich alles umrechne, dann hab ichs so versucht, weil irgendwie hat das mit else nicht funktioniert, aber so macht der dann immer mehrer Rechnungen...
Delphi-Quellcode:
procedure TForm1.EurobuttonClick(Sender: TObject);
var rZahl, rOperand, rErgebnis: real;
begin
  if
  length(Euro.Text)>=1
  then
  rZahl:= StrToFloat ( Euro.Text);
  rOperand:= 1.25;
  rErgebnis:= rZahl*rOperand;
  Dollar.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Euro.Text);
  rOperand:= 0.79;
  rErgebnis:= rZahl*rOperand;
  Pfund.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Euro.Text);
  rOperand:= 40.18;
  rErgebnis:= rZahl*rOperand;
  Rubel.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Euro.Text);
  rOperand:= 99.76;
  rErgebnis:= rZahl*rOperand;
  Yen.Text:= FloatToStr ( rErgebnis);

  if

  length(Dollar.Text)>=1

  then

   rZahl:= StrToFloat ( Dollar.Text) ;
  rOperand:= 0.79;
  rErgebnis:= rZahl*rOperand ;
  Euro.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Dollar.Text) ;
  rOperand:= 0.63;
  rErgebnis:= rZahl*rOperand ;
  Pfund.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat (Dollar.Text) ;
  rOperand:= 32.07;
  rErgebnis:= rZahl*rOperand ;
  Rubel.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Dollar.Text) ;
  rOperand:= 79.63;
  rErgebnis:= rZahl*rOperand ;
  Yen.Text:= FloatToStr ( rErgebnis);



  if length(Pfund.Text)>=1

  then
  rZahl:= StrToFloat ( Pfund.Text) ;
  rOperand:= 1.25;
  rErgebnis:= rZahl*rOperand ;
  Euro.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Pfund.Text) ;
  rOperand:= 1.56;
  rErgebnis:= rZahl*rOperand ;
  Dollar.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat (Pfund.Text) ;
  rOperand:= 50.23;
  rErgebnis:= rZahl*rOperand ;
  Rubel.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Pfund.Text) ;
  rOperand:= 124.73;
  rErgebnis:= rZahl*rOperand ;
  Yen.Text:= FloatToStr ( rErgebnis);

  if length(Rubel.Text)>=1
  then
  rZahl:= StrToFloat ( Rubel.Text) ;
  rOperand:= 0.02;
  rErgebnis:= rZahl*rOperand ;
  Euro.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Rubel.Text) ;
  rOperand:= 0.03;
  rErgebnis:= rZahl*rOperand ;
  Dollar.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat (Rubel.Text) ;
  rOperand:= 0.01;
  rErgebnis:= rZahl*rOperand ;
  Pfund.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Rubel.Text) ;
  rOperand:= 2.48;
  rErgebnis:= rZahl*rOperand ;
  Yen.Text:= FloatToStr ( rErgebnis);


  if length(Yen.Text)>=1

  then
  rZahl:= StrToFloat ( Yen.Text) ;
  rOperand:= 0.010;
  rErgebnis:= rZahl*rOperand ;
  Euro.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Yen.Text) ;
  rOperand:= 0.012;
  rErgebnis:= rZahl*rOperand ;
  Dollar.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Yen.Text) ;
  rOperand:= 0.008;
  rErgebnis:= rZahl*rOperand ;
  Pfund.Text:= FloatToStr ( rErgebnis);

  rZahl:= StrToFloat ( Yen.Text) ;
  rOperand:= 0.402;
  rErgebnis:= rZahl*rOperand ;
  Rubel.Text:= FloatToStr ( rErgebnis);

   end;
Danke schonmal im vorraus

Geändert von mkinzler (29. Mai 2012 um 08:11 Uhr) Grund: Delphi-Tag eingefügt
  Mit Zitat antworten Zitat