| Autor |
Beitrag |
Becks16
      
Beiträge: 405
|
Verfasst: Do 19.10.06 18:58
hallo
habe da ein problem
und zwar möchte ich mehrere editfelder addieren funktioniert ja auch aber wenn mal in einem editfeld nichts drin ist funktioniert das nicht ...bekommt man das irgendwie hin das er trotzdem rechnet aber im editfeld soll er nix rein schreiben keine 0 oder so
hier mal der quelltext
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| procedure Tf_kachelkamin.btn_berechnenClick(Sender: TObject); var a, b,d,e,f, c: real; begin
a := StrToFloat(edit_preis.Text); b := StrToFloat(edit_preiskachelkamin.Text); d := StrToFloat(edit_preisschuerzen.Text); e := StrToFloat(edit_preisregale.Text); f := StrToFloat(edit_preisregale2.Text);
c := a+b+d+e+f; edit_listenpreisgesamt.Text := FloatToStr(c); if edit_verkaufspreis.Text = '' then ShowMessage ('Es ist nichts zu berechnen da ') else begin
a := StrToFloat(edit_listenpreisgesamt.Text); b := StrToFloat(edit_verkaufspreis.Text); c := b*100/a-100; edit_rabatt.Text := FloatToStr(c);
a := StrToFloat(edit_listenpreisgesamt.Text); b := StrToFloat(edit_verkaufspreis.Text); c := b-a; edit_rabattgeld.Text := FloatToStr(c); end; end; |
vielen dank schon mal
mfg
_________________ Ich bin Dumm und weiss nichts
|
|
Chatfix
      
Beiträge: 1583
Erhaltene Danke: 10
Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
|
Verfasst: Do 19.10.06 19:01
Mach doch eine if-abfrage für jedes Eingabefeld...
_________________ Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
|
|
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 19.10.06 19:02
Du prüfst ja auch nicht, ob die Edits alle leer sind. Du hast schon eine Abfrage drin:
Delphi-Quelltext 1:
| if edit_verkaufspreis.Text = '' then ... |
Genauso machst du das beim vor dem Einlesen der Werte (a := strtofloat(...)).
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Becks16 
      
Beiträge: 405
|
Verfasst: Do 19.10.06 19:11
ich hab das jetzt so
funktioniert aber nicht
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42:
| procedure Tf_kachelkamin.btn_berechnenClick(Sender: TObject); var a, b,d,e,f, c: real; begin
if edit_preis.Text = ''then begin
b := StrToFloat(edit_preiskachelkamin.Text); d := StrToFloat(edit_preisschuerzen.Text); e := StrToFloat(edit_preisregale.Text); f := StrToFloat(edit_preisregale2.Text);
c := b+d+e+f; edit_listenpreisgesamt.Text := FloatToStr(c); end; begin a := StrToFloat(edit_preis.Text); b := StrToFloat(edit_preiskachelkamin.Text); d := StrToFloat(edit_preisschuerzen.Text); e := StrToFloat(edit_preisregale.Text); f := StrToFloat(edit_preisregale2.Text);
c := a+b+d+e+f; edit_listenpreisgesamt.Text := FloatToStr(c); if edit_verkaufspreis.Text = '' then ShowMessage ('Es ist nichts zu berechnen da ') else begin
a := StrToFloat(edit_listenpreisgesamt.Text); b := StrToFloat(edit_verkaufspreis.Text); c := b*100/a-100; edit_rabatt.Text := FloatToStr(c);
a := StrToFloat(edit_listenpreisgesamt.Text); b := StrToFloat(edit_verkaufspreis.Text); c := b-a; edit_rabattgeld.Text := FloatToStr(c);
end; end; end; |
mfg
_________________ Ich bin Dumm und weiss nichts
|
|
stifflersmom
      
Beiträge: 194
XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
|
Verfasst: Do 19.10.06 19:42
Die ganze Routine wird Dir wohl keiner schreiben,
aber wenn Du die folgenden Zeilen mal auf Deinen Code überträgst wirst Du es wohl selber hinkriegen
Delphi-Quelltext 1: 2: 3:
| if edit_preiskachelkamin.Text <> '' Then b := StrToFloat(edit_preiskachelkamin.Text) else b:=0; |
Moin
|
|
Becks16 
      
Beiträge: 405
|
Verfasst: Do 19.10.06 19:58
hmmm krieg ich nicht hin dazu bin ich zu blöd
_________________ Ich bin Dumm und weiss nichts
|
|
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 19.10.06 19:59
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Becks16 
      
Beiträge: 405
|
Verfasst: Do 19.10.06 20:02
hier ist das hmm habe es erst mal aus einer anderen form genommen wo erst mal nur 2 felder sind
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| procedure Tf_schornstein.btn_berechnenClick(Sender: TObject); var a, b,d,e,f, c: real; begin if edit_preisschornstein.Text <> '' Then a := StrToFloat(edit_preisschornstein.Text) else a:=0;
b := StrToFloat(Edit1.Text); c := b; edit_listenpreisgesamt.Text := FloatToStr(c);
a := StrToFloat(edit_preisschornstein.Text); b := StrToFloat(Edit1.Text); c := a+b; edit_listenpreisgesamt.Text := FloatToStr(c); |
_________________ Ich bin Dumm und weiss nichts
|
|
Becks16 
      
Beiträge: 405
|
Verfasst: Fr 20.10.06 09:05
so ich habe das jetzt hin bekommen
müsste so richtig sein also funktionieren tut das
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| if edit_preisschornstein.Text <> '' Then a := StrToFloat(edit_preisschornstein.Text) else a:=0;
if Edit1.Text <> '' Then b := StrToFloat(Edit1.Text) else b:=0;
c := a+b; edit_listenpreisgesamt.Text := FloatToStr(c); |
mfg
_________________ Ich bin Dumm und weiss nichts
|
|