Autor Beitrag
Becks16
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: 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
ausblenden 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);
      //  edit_listenpreisgesamt.Text := Format('%6.2n',[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
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
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
BeitragVerfasst: 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.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 19.10.06 19:02 
Du prüfst ja auch nicht, ob die Edits alle leer sind. Du hast schon eine Abfrage drin:
ausblenden 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 19.10.06 19:11 
ich hab das jetzt so

funktioniert aber nicht

ausblenden volle Höhe 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:
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 = ''// ich weiss nicht genau was hier hin kommt 
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);
      //  edit_listenpreisgesamt.Text := Format('%6.2n',[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
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: 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

ausblenden Delphi-Quelltext
1:
2:
3:
if  edit_preiskachelkamin.Text <> '' Then
 b := StrToFloat(edit_preiskachelkamin.Text)
else b:=0;

Moin
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: 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.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 19.10.06 19:59 
user profile iconBecks16 hat folgendes geschrieben:
hmmm krieg ich nicht hin dazu bin ich zu blöd

:mrgreen:
Poste mal, was du bis jetzt hast. Und hole dir mal ein Buch über Delphi. Oder schaue dir mal Christian's Crashkurs an. Bei dir mangelt es arg an den Grundlagen. ;)

_________________
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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: 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

ausblenden 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Fr 20.10.06 09:05 
so ich habe das jetzt hin bekommen

müsste so richtig sein also funktionieren tut das

ausblenden 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 :-)