Ver Mensaje Individual
  #2  
Antiguo 11-09-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Partimos de que tienes 5 edits (Edit1 ... Edit5) y que todos comienzan sin tener nada escrito. En el evento OnKeypress de cada uno coloca esto (sirve el mismo evento para todos).

Código Delphi [-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
  s: string;
begin
  // Solo nos interesan las teclas del 1 al 5 y la de borrar
  if key in ['1'..'5',#8] then
  begin
    // Si queremos introducir un numero
    if Key in ['0'..'9'] then
      // Comprobamos que el edit esta vacio
      if Length((Sender as TEdit).Text) = 0 then
      begin
        s:= key;
        // Y comprobamos que no este en otro edit
        if (s = Edit1.Text) or (s = Edit2.Text) or
           (s = Edit3.Text) or (s = Edit4.Text) or
           (s = Edit5.Text) then Key:= #0; // Si ya esta en otro edit ignoramos la tecla
      end else
        Key:= #0; // Si no esta vacio ignoramos la tecla
  end else
    Key:= #0; // Si no es un numero o la tecla de borrar la ignoramos
end;
Responder Con Cita