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


9 Years
Discussion Span
Last Post by jsosnowski

Here the code for solving this:

Votes + Comments
gave me some code to help solve my delphi problem ^_^

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.