Ver Mensaje Individual
  #5  
Antiguo 10-06-2008
luigi_cr luigi_cr is offline
Miembro
 
Registrado: jul 2007
Ubicación: Costa Rica
Posts: 39
Reputación: 0
luigi_cr Va por buen camino
Thumbs up

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:= EditMask;
        //Delete(S, Length(s)-3, 4);
        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
Código Delphi [-]
if key = #8 then
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.
Responder Con Cita