Autor Beitrag
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 03.11.05 09:43 
hi leutz
ich hab ein programm geschreiben mit dem man die
Tankfüllung ausrechnen kann d.h. ich geb ne literzahl an und drüch dan auf die benzin sorte und der zeigt mir dan den preis an.

doch das funktionirt bei mir net richtig

ich hab en butto1(benzin) und neben dran en edit2 wo man den preis reinschreiben muss
und oben einen button wo ich die getankte literzahl eingeben muss(edit1)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
Form1: TForm1;
zahl1:single;
zahl2: single
ergebnis: single;


procedure Tform1.Button1Click(sender:TObjekt);
begin
zahl1:=strtofloat (edit1.text);
zahl2:=strtofloat (edit2.text);
ergebnis := Zahl1*Zahl2;
edit5.text:= floattostrF (ergebnis,fffixed,4,2);
end;


warum funktioniert das net

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 03.11.05 09:51 
Die Frage ist: Was funktioniert denn nicht? Liefert das Programm nicht das gewünschte Ergebnis, kommt zur Laufzeit ne Fehlermeldung, oder compiliert er erst gar nicht?
Letzteres könnte daran liegen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var   
Form1: TForm1;   
zahl1:single;   
zahl2: single;
ergebnis: single;

_________________
We are, we were and will not be.
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 03.11.05 09:56 
oh das hab ich vergessen es bringt kein ergebnis
Jimbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Do 03.11.05 10:00 
kann natürlich für nichts garantieren aber ich würds mal so probieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
Form1: TForm1;
zahl1, zahl2, ergebnis: real;

procedure Tform1.Button1Click(sender:TObjekt);
begin
zahl1:=strtofloat (edit1.text);
zahl2:=strtofloat (edit2.text);
ergebnis := Zahl1*Zahl2;
edit5.text:= floattostr (ergebnis);
end;


jetzt musst du nur noch das ergebnis etwas abrunden und eventuell beschneiden.

_________________
Besucht doch mal meine Webseite: jdallmeyer.de
Hier findet Ihr ein paar meiner Projekte.
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 03.11.05 10:01 
danke