procedure ValidarPorcentajeKeyPressEdit(Caracter: Char;Edit:TrDBEdit);
var
pos: Cardinal;
begin
i:=0;
if ( StrScan('0123456789.,'+chr(7)+chr(8)+#13, Caracter) = nil ) then Caracter := #0;
if (Caracter = '.') or (Caracter = ',') then Caracter := ',';
for i := 1 to length(Edit.Text) do
if ( copy((Edit.Text), i , 1) = ',' ) and not ( StrScan(',', Caracter) = nil ) then Caracter := #0;
with Edit as TrDBEdit do
begin
pos := System.Pos(',', Text);
if not LongBool(Pos) then Dec(Pos);
ReadOnly := not (Caracter in ['0'..'9',#13, ',', #8]) or
(Pos <> $FFFFFFFF) and (Caracter = ',') or
((Caracter <> #8) and (Caracter <> #13) and (Pos < (SelStart - 1)));
end;
end;
procedure TForm.DBPorcentajeKeyPress(Sender: TObject; var Key: Char);
begin
ValidarPorcentajeKeyPressEdit(Key,Sender AS TrDBEdit);
end;