AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Taschenrechner Programmieren

Ein Thema von Jack Ryan · begonnen am 16. Apr 2004 · letzter Beitrag vom 29. Sep 2004
Antwort Antwort
Benutzerbild von Nothine
Nothine

Registriert seit: 3. Jul 2004
Ort: Mülheim an der Ruhr
198 Beiträge
 
Delphi 5 Enterprise
 
#1

Re: Taschenrechner Programmieren

  Alt 29. Sep 2004, 19:18
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var Eingabe,Ergebnis: Real;
    Einheit,EinheitNeu: string;
begin
  Eingabe := StrToFloat(Edit1.Text); //StrToFLOAT !
  Einheit := Edit2.Text;
  EinheitNeu := Edit3.Text;
  Ergebnis := 0;

  if (UpperCase(Einheit)='CM') and (UpperCase(EinheitNeu)='DM') then
    Ergebnis := Eingabe / 10;
  if (UpperCase(Einheit)='CM') and (UpperCase(EinheitNeu)='M') then
    Ergebnis := Eingabe / 100;
  if (UpperCase(Einheit)='MM') and (Uppercase(EinheitNeu)='KM') then
    Ergebnis := Eingabe / 1000000;
  if (UpperCase(Einheit)='DM') and (UpperCase(EinheitNeu)='CM') then
    Ergebnis := Eingabe * 10;
  if (UpperCase(Einheit)='M') and (UpperCase(EinheitNeu)='DM') then
    Ergebnis := Eingabe * 10;
  if (UpperCase(Einheit)='M') and (UpperCase(EinheitNeu)='CM') then
    Ergebnis := Eingabe * 100;
  if (UpperCase(Einheit)='M') and (UpperCase(EinheitNeu)='MM') then
    Ergebnis := Eingabe * 1000;
  if (UpperCase(Einheit)='KM') and (UpperCase(EinheitNeu)='M') then
    Ergebnis := Eingabe * 1000;
  if (UpperCase(Einheit)='KM') and (UpperCase(EinheitNeu)='MM') then
    Ergebnis := Eingabe * 1000000;

  Label5.Caption := FloatToStr(Ergebnis) + EinheitNeu;
end;
so sollte deine button-prozedur aussehen... (abgesehn davon dass noch nicht alle kombinationen drin sind )

//Edit: und das mit UpperCase und LowerCase is reine geschmackssache...
if ThisPost is senseless then
ThisPost.WasPostedBy := SomeoneElse();
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz