Topic: Format Float

Happy New Year to all.............


How can I format currency field with thousand separator and decimals when field value is called from an another form?
For example, I like the field "Price" on form1 display 42,562,314.25 not 4256231425


I tried the following script but didn't work:

// ***** if the user is scrolling through the grid using the keyboard
procedure Form1_TableGrid1_OnKeyUp (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
var
  i,c: integer;

begin
  Form1.edName.Text := SQLExecute('SELECT itemName FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  Form1.edPrice.Text := SQLExecute('SELECT price FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  //Form1.edPrice.text := FormatFloat('#,##0.00', Form1.edPrice.text);

end;


//***** if the user is scrolling through the grid using the mouse
procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
var
  i,c: integer;

begin
  Form1.edName.Text := SQLExecute('SELECT itemName FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  Form1.edPrice.Text := SQLExecute('SELECT price FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  //Form1.edPrice.text := FormatFloat('#,##0.00', Form1.edPrice.text);

end;

Please see the attached sample project.

Post's attachments

Attachment icon formatFloat.zip 3.92 kb, 365 downloads since 2016-12-30 

Adam
God... please help me become the person my dog thinks I am.

Re: Format Float

Hello.

Sorry for delay. I was on vacation.
The question is still relevant for you?

Dmitry.

Re: Format Float

Hi Dmitry,


Yes, I still couldn't find an answer.

Adam
God... please help me become the person my dog thinks I am.

Re: Format Float

Check it out

Form1.edPrice.Value := SQLExecute('SELECT price FROM inv WHERE id='+form1.TableGrid1.sqlValue);
Dmitry.

Re: Format Float

DriveSoft wrote:

Check it out

Form1.edPrice.Value := SQLExecute('SELECT price FROM inv WHERE id='+form1.TableGrid1.sqlValue);

Thanks a lot Dmitry.............
It does the job.

Adam
God... please help me become the person my dog thinks I am.