Ver Mensaje Individual
  #9  
Antiguo 24-10-2018
TavoBran TavoBran is offline
Miembro
NULL
 
Registrado: oct 2018
Posts: 13
Reputación: 0
TavoBran Va por buen camino
Amigo muchas gracias por su ayuda ya busque y pude solucionar mi error

les dejo mi solucion y me dicen que les parece

Código Delphi [-]

unit Ejecucion;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Menus;

type
  matriz = array of array of Integer;
  TfrmEjecucion = class(TForm)
    Button1: TButton;
    Edt: TEdit;
    Panel1: TPanel;
    Panel2: TPanel;
    Button2: TButton;
    Button3: TButton;
    MainMenu1: TMainMenu;
    Volver1: TMenuItem;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Volver1Click(Sender: TObject);
  private
    { Private declarations }
  public
    NEdits : Integer;
    Edits: TEdit;
    m : matriz;
    f,c : Integer;
    con : Integer;
  end;

var
  frmEjecucion: TfrmEjecucion;


implementation

{$R *.dfm}

procedure TfrmEjecucion.Button1Click(Sender: TObject);
var
  i,j : Integer;
begin
  if Trim(Edt.Text) = '' then
  begin
    ShowMessage('Debe escribir un número');
    Exit;
  end;
  //Desicion para que no sea tan grande la matriz
  if StrToInt(Edt.Text) >= 11 then
  begin
    ShowMessage('El valor tiene que ser igual o menor a 10');
    Edt.Clear;
  end
  else
  begin
    //Establece el valor de la matriz y de los TEdit
    c := StrToInt(Edt.Text);
    f := StrToInt(Edt.Text);
    SetLength(m, StrToInt(Edt.Text),StrToInt(Edt.Text));
    Button1.Visible := False;
    Edt.Visible := False;
  end;
  //Creo y posiciono los Edits
 for i := 1 to c do
  begin
    for j := 1 to f do
    begin
      Edits := TEdit.Create(Self);
      Edits.Name := 'Edit' + IntToStr(i) + IntToStr(j);
      Edits.Text := '';
      Edits.Top := 21 * (i + 1);
      Edits.Left := 21 * (j + 1);
      Edits.Width := 20;
      Edits.Height := 20;
      Edits.AutoSize := False;
      Edits.Enabled := False;
      Edits.Parent := Panel1;
      Button3.Visible := True;
    end;
  end;
end;


procedure TfrmEjecucion.Button2Click(Sender: TObject);
begin
  m := nil;
end;

procedure TfrmEjecucion.Button3Click(Sender: TObject);
var
  i,j,c : Integer;
  Comp : TComponent;
begin
  //Agrega numeros a la matriz aleatoriamente.
  c := StrToInt(Edt.Text);
  For i := 0 to c do
  begin
    for j := 0 to c do
    begin
       Comp := FindComponent ('Edit' + IntToStr(i)+ IntToStr(j));
       if Assigned (Comp) then
       begin
         (Comp as TEdit).Text := IntToStr(Random(100));
       end;
    end;
  end;

end;

procedure TfrmEjecucion.Volver1Click(Sender: TObject);
begin
    Close;
end;

end.
Responder Con Cita