Ver Mensaje Individual
  #16  
Antiguo 25-10-2018
TavoBran TavoBran is offline
Miembro
NULL
 
Registrado: oct 2018
Posts: 13
Reputación: 0
TavoBran Va por buen camino
Post

roman si eso yo lo defino como me dices solo que tengo otra duda

este es mi codigo

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
  TMatriz = array of array of TEdit;
  TfrmEjecucion = class(TForm)
    Button1: TButton;
    Edt: TEdit;
    Panel1: TPanel;
    Panel2: TPanel;
    Button2: TButton;
    Button3: TButton;
    MainMenu1: TMainMenu;
    Volver1: TMenuItem;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmEjecucion: TfrmEjecucion;
  m : TMatriz;
  ma : Integer;

implementation

{$R *.dfm}

procedure CrearEdits(Edits:TMatriz);
var
  i,j :integer;
begin
  for i := 1 to ma do
  begin
    for j := 1 to ma do
    begin
      Edits[i,j]:=TEdit.Create(Self);
      Edits[i,j].Text := '';
      Edits[i,j].Top := 21 * (i + 1);
      Edits[i,j].Left := 21 * (j + 1);
      Edits[i,j].Width := 20;
      Edits[i,j].Height := 20;
      Edits[i,j].AutoSize := False;
      Edits[i,j].Enabled := False;
      Edits[i,j].Parent := Panel1;
    end;
  end;
end;


procedure llenarEdits(Edits:TMatriz);
var
  i, j:integer;
begin
  for i:=1 to ma do
  begin
    for j:=1 to ma do
    begin
      Edits[i,j].text := IntToStr(Random(100));
    end;
  end;
end;

procedure TfrmEjecucion.Button1Click(Sender: TObject);
var
  matriz:TMatriz;
  i,j : Integer;
begin
  if Trim(Edt.Text) = '' then
  begin
    ShowMessage('Debe escribir un número');
    Exit;
  end;
  //Grivera 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
    ma := StrToInt(Edt.Text);
    SetLength(m, StrToInt(Edt.Text),StrToInt(Edt.Text));
    Button1.Visible := False;
    Edt.Visible := False;
  end;
  CrearEdits(matriz);
  llenarEdits(matriz);
end;

end.

pero me genera dos errores que son al momento de crear los edit

Código Delphi [-]

Edits[i,j]:=TEdit.Create(Self);  // [dcc32 Error] Ejecucion.pas(46): E2003 Undeclared identifier: 'Self'
Edits[i,j].Parent := Panel1;  //[dcc32 Error] Ejecucion.pas(54): E2003 Undeclared identifier: 'Panel1'

lo tengo asi pero me genera error en esas dos lineas de codigo
Responder Con Cita