Jump to content

DecimalSeparator field type in a numeric (float)?


Recommended Posts

Posted

How do I change the decimal points to commas in a field type numeric (float)?

 

Example VCL:

 

procedure TFrmCadNotalFiscal.UniDBEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = '.' then
    Key := DecimalSeparator; // ','
end;
 
Does anyone have any concrete example of how to solve these problems with viewing and editing numeric fields?
 
Masks such as:  # # #, # # #, # #0.00 do not work for editing WebMode.
 
Any solution?
Posted

Bom dia Eduardo eu utilizo uma função para isso:

 

Obs: Isso Para o Banco MYSQL

 

No evento OnExit:

FormataValor(TuniEdit1.Text);

function FormataValor(edit:TuniEdit):String;
var
   s : string;
   v : double;
   I : integer;
begin
  try
   if edit.Text = EmptyStr then
      edit.Text := '0';

   {obter o texto do edit, SEM o ponto decimal}
   s := '';
   for I := 1 to length(edit.Text) do
   if (edit.Text[I] in ['0'..'9',',']) then
      s := s + edit.Text[I];

   if s = EmptyStr then
      s := '0';

   {fazer com que o conteúdo do edit apresente 2 casas decimais}
   v := strtofloat(s);

   {Formata o valor de (V) para aceitar valores do tipo 0,10}
   edit.Text := FormatFloat('0.00',v);

   edit.Color  := clWhite;
   except
    on e: exception do
      begin
        ShowMessage('Este Campo só é permitido números.');
        edit.Text   := EmptyStr;
        edit.Color  := clYellow;
        edit.SetFocus;
      end;
  end;
Posted

Olá Marlon!

 

Aqui não funcionou. Ao chamar FormataValor(UniEdit1.Text) dá o erro:

 

E2010 Incompatible Types: 'TUniEdit' and 'TCaption'

 

Alterei para FormataValor(UniEdit1) e passou, mas não está formatando:

 

Se por exemplo faço: 100,50 retorna 10050,00

 

O que pode ser?

 

Outra coisa, se for utilizar TUniDBEdit com campo Float dá o erro:

is not a Valid BCD Value 

 

Obrigado por ajudar.

Posted

Referente ao Erro:

 

"E2010 Incompatible Types: 'TUniEdit' and 'TCaption'"

 

voce deve apenas colocar o "Tuniedit1" sem o Caption ou Text.

 

Ex: FormataValor(Uniedit1);

 

 

"se for utilizar TUniDBEdit"

 

quando voce tem TuniDBEdit, voce deve utilizar da seguinte forma:

 

FormataValor(TUniEdit(UNIDBEDTI1));

 

Att, Marlon Nardi

Posted

Referente ao Erro:

 

"E2010 Incompatible Types: 'TUniEdit' and 'TCaption'"

 

voce deve apenas colocar o "Tuniedit1" sem o Caption ou Text.

 

Ex: FormataValor(Uniedit1);

 

 

"se for utilizar TUniDBEdit"

 

quando voce tem TuniDBEdit, voce deve utilizar da seguinte forma:

 

FormataValor(TUniEdit(UNIDBEDTI1));

 

Att, Marlon Nardi

 

I still have the same problem (Continuo com o mesmo problema).

 

Any other tips? (Alguma outra dica?)

Posted

Englishi Please !!!

 

I still can not solve the problem with formatting numeric fields using UniDBEdit.
 
Someone else can help?

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...