Quería llamar la atención sobre un pequeño detalle, y es que usando directamente el evento
Edit1KeyPress, el código se ejecuta
antes de actualizarse el TEdit (al menos en mi querido Delphi 3. ¿No sería mejor utilizar un
Timer?:
Código Delphi
[-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
Timer1.Enabled:= True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
IF Trim(Edit1.Text)=''THEN
BEGIN
IF(Key=#69)OR(Key=#86)THEN Exit
ELSE
Key:=#0;
END
ELSE
BEGIN
IF Key = #8 THEN Exit; IF (Key<#48)OR(Key > #58) THEN
Key:=#0;
END;
end;
Timer1.Enabled:= False;
End;
Asimismo, en el
Object inspector conviene ponerle al
Timer las propiedades
Enable a
False e
Interval a 1.