Accepting input from a TEdit box. I want to be able to be able to handle this if a real number (with decimal point) is entered. Would also like to convert this to an integer type. It was easy in Pascal 7 but I don't see it in the Delphi help files.
{with}<br>
var<br>
s:string; <br>
x:real;<br>
n:integer;<br>
<br>
.....<br>
s := edit1.text;<br>
x := strtofloat(s);<br>
n := round(x);<br>
<br>
{to show result}<br>
edit1.text := floattostr;<br>
{This works whether or not text is a real number}<br>
{Error checking can be added to determine whether text is a number at all}
Try with the :
function FormatFloat(const Format: string; Value: Extended)
and for Format you can see the Delphi Help to presice your format.
I hope it can work.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.