Ver Mensaje Individual
  #2  
Antiguo 18-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola javave.

Podés asignar esto al evento OnExit del TEdit:
Código Delphi [-]
procedure TForm1.ValorExit(Sender: TObject);
var
  Value: Integer;
begin
  if not TryStrToInt(Valor.Text, Value) then
  begin
    ShowMessage('No ingresó un número');
    Valor.SetFocus;
  end;
end;

O directamente evitar que lo ingrese, asignando esto al evento OnKeyPress del TEdit:
Código Delphi [-]
procedure TForm1.ValorKeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in [#8,#13,'0'..'9']) then // teclas permitidas BacSpace,Intro,'0'..'9'
  begin
    Beep;
    Key:= #0;
  end;
end;

Hay otras opciones, pero creo que estas son simples y te funcionaran bién.

Saludos.
Responder Con Cita