Entwickler-Ecke

Delphi Language (Object-Pascal) / CLX - Delphi Insert befehl


johi23 - Di 12.11.13 18:50
Titel: Delphi Insert befehl
Hallo,
Ich möchte bei delphi an ein ergebnis etwas anhängen:


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button2Click(Sender: TObject);

var a,b, fall:real;

begin

a:= strtofloat (edit1.Text);
b:= 9.81;

fall:= sqrt ((2*a)/b);

fall:= fall*100;
fall:= round (fall);
fall:= fall/100;

label2.Caption:= floattostr (fall);

end;

end.


Es handelt sich um ein kleines programm welches die Fallgeschwindigkeit berechnet. Ich möchte an das Ergenis ein 's' anhängen. Leider hat das bisher noch nicht funktioniert :/

Moderiert von user profile iconMartok: Delphi-Tags hinzugefügt


Mathematiker - Di 12.11.13 19:10

Hallo,
Strings können addiert werden, d.h. Du kannst

Delphi-Quelltext
1:
label2.Caption:= floattostr(fall)+' s';                    

schreiben.
Alternativ geht auch die Verwendung des format-Befehls, der Dir zusätzlich die Möglichkeit gibt, die Anzahl der ausgegebenen Ziffern bei floattostr einzustellen.

Beste Grüße
Mathematiker


Tranx - Di 12.11.13 19:29

Es geht auch mit


Delphi-Quelltext
1:
label2.Caption:= FormatFloat('#,##0.00 s',fall);