Hola Soa Pelaez,
Sólo quieres controlar si al pulsar un (.) se cambie por una (,) y delimitar el número de decimales que puedes introducir, pues yo utilizo esto.
Código Delphi
[-]
procedure ValidOnKeyPress(var Key: Char; MaxDecimals: Integer; Text: String);
const
WVK_POINT = '.';
WVK_COMMA = ',';
WVK_NULL = #0;
WVK_BACKDELETE = #8;
function CountDecimals: Byte;
var
nPos: Integer;
begin
Result := 0;
nPos := Pos(',', Text);
if (nPos <> 0) or (nPos <> Length(Text)) then
Result := (Length(Text) - nPos);
end;
begin
if (Key = WVK_POINT) then
Key := WVK_COMMA;
if not (Key in ['0'..'9', WVK_BACKDELETE, WVK_COMMA]) then
Key := WVK_NULL;
if (Key = WVK_COMMA) and (Pos(WVK_COMMA, Text) > 0) then
Key := WVK_NULL;
if (CountDecimals = MaxDecimals) and (not (Key = WVK_BACKDELETE)) then
Key := WVK_NULL;
end;
Y la llamada lo hacemos asi.
Código Delphi
[-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
ValidOnKeyPress(Key, 2, Edit1.Text);
end;
O
Código Delphi
[-]
procedure TForm1.DBEdit1KeyPress(Sender: TObject; var Key: Char);
begin
ValidOnKeyPress(Key, 2, DBEdit1.Text);
end;
Un saludo.