Tema: Validar Edit
Ver Mensaje Individual
  #3  
Antiguo 31-07-2007
Avatar de MaMu
MaMu MaMu is offline
Miembro
 
Registrado: abr 2006
Ubicación: Argentina
Posts: 863
Reputación: 21
MaMu Va por buen camino
Yo lo primero que haria es limitar al TEdit a solo numero, asi:

Código Delphi [-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
 if ( StrScan('0123456789',Key) <> nil ) or
      ( Key = Char(VK_BACK) ) then
   begin
     {Aqui tu tratamiento normal del evento}
   end
   else
     Key := #0;
end;

Luego definiria el ancho minimo que deseo que ingresen, asi:

Código Delphi [-]
Edit1.MaxLength:=10;

Y luego, para verificar que no este vacio, ni menor a 10, asi:

Código Delphi [-]
 if Length(Edit1.Text)<10
  then begin
     ShowMessage('Introduzca 10 numeros');
     Edit1.SetFocus;
     Exit;
 end;

// si hay 10 continuamos aqui
.....

Saludos
__________________
Código Delphi [-]
 
try 
ProgramarMicro(80C52,'Intel',MnHex,True);
except
On Exception do
MicroChip.IsPresent(True);
end;
Responder Con Cita