Autor Beitrag
WormHole
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 145



BeitragVerfasst: Do 26.05.05 19:49 
Hallo,

ganz kurz und knapp. Ich möchte gerne eine Kommazahl durch eine Kommazahl dividieren, und das Ergebnis dann in einem Label zeigen.

Beispiel:
a= 5,43
b= 4,23
c= 1,23168...
Label1.Caption = ???toStr(c)

thx in advance
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 26.05.05 19:57 
FloatToStr
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Do 26.05.05 20:24 
Float steht für ne Fließkommazahl. Fließkommazahlen sind so ziemlich alle außer Integerwerte.
WormHole Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 145



BeitragVerfasst: Do 26.05.05 20:27 
und was müssen a und b und c dann sein? Extended?
JayK
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Do 26.05.05 20:34 
user profile iconWormHole hat folgendes geschrieben:
und was müssen a und b und c dann sein? Extended?

Single, Double oder Extended
edit:
Können aber auch andere, wie Integer, sein. Das Ergebnis ist ja für FloatToStr entscheident ;)


Zuletzt bearbeitet von JayK am Do 26.05.05 20:35, insgesamt 1-mal bearbeitet
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Do 26.05.05 20:34 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
....

var
  Form1: TForm1;
  a,b,Ergebnis:Real;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  a:= 5.43;
  b:= 4.23;
  Ergebnis:= a / b;
  Label1.caption := FloatToStr(Ergebnis);// Genau
  Label2.caption := FloatToStrF(Ergebnis,ffNumber,8,2);// Auf zwei Stellen gerundet
end;
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Do 26.05.05 20:56 
Da auf a und b ja auch Kommazahlen zugewiesen werden können die auch net Integer sein.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
a,b,Erg: real;  //Exetendet, Currencey, ....
begin
a := 5,34;
b := 4,89;
Erg := a/b;
Label1.caption := Floattostr(Erg);
Label2.caption := formatfloat('0.00',erg); //Bis auf 2 Kommastellen anzeigen
end;
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Do 26.05.05 21:00 
OK danach war aber nicht die Frage...
WormHole Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 145



BeitragVerfasst: Do 26.05.05 21:00 
thx a lot. Jetzt habe ich auch das prob gefunden, warum das bei mir nicht geklappt hat.... Ich trottel

Ich hatte:
a:= StrtoInt(Edit1.Text);
usw...
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Do 26.05.05 21:02 
Dieselbige ist doch schon beantwortet.