Ver Mensaje Individual
  #6  
Antiguo 23-03-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
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 Chino150.

Sumo otra alternativa a las que ya te han sugerido los compañeros:
Código Delphi [-]
...
interface

(* Inicializar TEdit's, asignar eventos *)
procedure TForm1.FormShow(Sender: TObject);
var
  i: Integer;
begin
  for i:= 0 to ComponentCount -1 do
    if Components[i] is TEdit then
    begin
      TEdit(Components[i]).Text:= ''; // aca poné lo que el profesor quiera que se visualice
      TEdit(Components[i]).OnKeyPress:= EditKeyPress;
      TEdit(Components[i]).OnChange:= EditChange;
    end;
end;

(* Verificar sólo números *)
procedure TForm1.EditKeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in [#8,'0'..'9']) then
  begin
    MessageBeep(MB_ICONERROR);
    Key:= #0;
  end;
end;

(* Verificar rango 1-10 *)
procedure TForm1.EditChange(Sender: TObject);
var
  v: Integer;
  s: string;
begin
  s:= TEdit(Sender).Text;
  if TryStrToInt(TEdit(Sender).Text, v)and(v < 1) or (v > 10)  then
  begin
    ShowMessage('Valor máximo/minimo permitidos: 1-10');
    TEdit(Sender).OnChange:= nil;
    Delete(s,Length(s),1);
    TEdit(Sender).Text:= s;
    TEdit(Sender).SelStart:= Length(s);
    TEdit(Sender).OnChange:= EditChange;
  end;
end;

Y coincido también que la petición es un poquito rebuscada...

Un saludo.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 23-03-2011 a las 22:17:40.
Responder Con Cita