Ver Mensaje Individual
  #6  
Antiguo 04-12-2008
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Bueno, yo también quiero. Sobre todo para dejar claro que cuando antes hablaba de "Components" y "ComponentsCount", en realidad quería decir "Controls" y "ControlsCount". Por lo demás, el siguiente código intenta un objetivo muy parecido al que Caral ha escrito arriba:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  errors: string;
const
  MSG_SEPARATOR = #13#13;
  EMPTY_EDIT_MSG = '%s edit is empty';
begin
  errors := '';
  for i := 0 to EditsPanel.ControlCount - 1 do
  begin
    if (EditsPanel.Controls[i] is TEdit) then
    begin
      if (Trim(TEdit(EditsPanel.Controls[i]).Text) = EmptyStr) then
      begin
        if (errors = EmptyStr) then begin
          errors := Format(EMPTY_EDIT_MSG,
           [TEdit(EditsPanel.Controls[i]).Name]);
        end else begin
          errors := errors + MSG_SEPARATOR + Format(
           EMPTY_EDIT_MSG, [TEdit(EditsPanel.Controls[i]).Name]);
        end;
      end;
    end;
  end;
  if (errors <> EmptyStr) then begin
    ShowMessage(errors);
  end else begin
    ShowMessage('All edits contain values');
  end;
end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita