Código Delphi
[-]procedure txtKeyPress(
Sender: TObject; var Key: Char);
var s, t: String;
i: integer;
begin
if key='.' then
with TMaskEdit(Sender) do
begin
t:= Trim(stripped('.', Text));
s:= '9';
for i := 0 to Length(Trim(stripped(' ', t))) - 2 do
begin
s:= s + '9';
EditMask:= S+'\.9999;1; ';
end;
Text:= stripped(' ', t);
SelStart:= Length(Trim(Text))-4;
end;
if key = #8 then
with TMaskEdit(Sender) do
begin
t := Trim (Text);
EditMask := '9999999999;1; ';
Text := stripped(' ', t);
SelStart:= Length(Trim(Text));
end;
end;
Al final lo deje algo asi.
El stripped es una función que elimina un determinado caracter en una cadena, en este caso el espacio en blanco.
el
es para cuando se presiona backspace.
el codigo de la función stripped es el siguiente:
Código Delphi
[-]function stripped(stripchar: char; str: string): string;
var
tmpstr : string;
begin
tmpstr := str;
while pos(stripchar, tmpstr) > 0 do
delete(tmpstr, pos(stripchar, tmpstr), 1);
stripped := tmpstr;
end;
Lo tome de aca:
http://www.q3.nu/trucomania/ftesp.html
Gracias por las respuestas.