I have a problem with my edit boxs.
I am adding value 0.1 to an edit box on a button click. How can I make it so that there is always 4 values i.e 00.1 if the value was 0.1. or 01.0 if the value is one.
At the moment i am using float to string values but any way of solving this problem works with me =)

I hope this makes sense =) if not I'll explain my problem in further detail

~bbradley

Recommended Answers

All 3 Replies

Here the code for solving this:
FormatFloat('00.0',StrToFloat(TheGTBox.Text));

commented: gave me some code to help solve my delphi problem ^_^ +1

I've tried out this code, but it doesn't work =(

when you say "TheGTBox.Text" do you just mean an edit box? Or is that part of the code that has to be used in order for the code to work.
Also where would I place this code? I originally placed it in the edit box.

FormatFloat is a function returning a string. The code is in the SysUtils Unit so you must verify it is included in the Uses statement. The GTBox.text should be changed to the name of your Tedit (TEdit1 ?) . You would enter the statement whereever you are assigning the text to the Edit component.

Edit1.text := FormatFloat ( '00.0', Floatnum);

FloatNum is the Float value you are converting. In Superseven's example he extracts the value from the current text string in the Tedit. "Delphi in a Nutshell" is an excellent language guide for reference

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.