请问怎样动态声明多个变量(比如循环的方式声明Form1,form2,form3,form4,....变量)!

解决方案 »

  1.   

    newForm: TFormfor i:= 0 to Number do
    begin
        newForm := TForm.Create(Self);
        newForm.Caption := "123";
    end
      

  2.   

    窗体属性你可以自己改比如:
    newForm.Caption := "newForm" + IntToStr(i);
      

  3.   

    var newForm: TForm;
    begin
      for i:= 0 to Number do
      begin
        newForm := TForm.Create(Self);
        newForm.name:='form'+inttostr(i);
        newForm.Caption := 'form'+inttostr(i);
      end
    end;
      

  4.   

    如果属性是一样的,可以用动态数组变量啊。  Form : Array of TForm;
      FormCount : Integer;
    初始化FormCount := 0;
    用到的时候,
      SetLength(Form,FormCount);
      Inc(FormCount);
      Form[FormCount-1] := TForm.Create(nil);
      ......
      

  5.   

    {$IF expression}
     语句1
    {$ELSE}
     语句2
     
    只有当expression为真时,编译器编译语句1,否则编译语句2
      

  6.   

    首先要看你想干什么?是不是把一批窗口<不相同的>管理起来?
    如果是的话可以使用数组。