Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Real type to integer type 1

Status
Not open for further replies.

Leo

Programmer
Mar 17, 1999
4
US
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(n);<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.
 
HI..
I want to conver the string in my text box become a decimal..
Do you know how to do it ??

I also want to make validation in my text box, that only number can be entered there, can you show me guys ???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top