Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms 我想通过单击另一个表单Delphi 7上的按钮来更改一个表单上标签的标题_Forms_Delphi - Fatal编程技术网

Forms 我想通过单击另一个表单Delphi 7上的按钮来更改一个表单上标签的标题

Forms 我想通过单击另一个表单Delphi 7上的按钮来更改一个表单上标签的标题,forms,delphi,Forms,Delphi,我得为学校做一个预测游戏。为了让两支随机的球队互相比赛,我在表格1中完成了以下代码: procedure TfrmUserInput.FormCreate(Sender: TObject); const arrT1 : array[1..6] of string = ('Blue Bulls','Griquas','EP Kings','Sharks','Cheetahs','Valke'); arrT2 : array[1..6] of string = ('Lions','Pumas','L

我得为学校做一个预测游戏。为了让两支随机的球队互相比赛,我在表格1中完成了以下代码:

procedure TfrmUserInput.FormCreate(Sender: TObject);
const
arrT1 : array[1..6] of string = ('Blue Bulls','Griquas','EP Kings','Sharks','Cheetahs','Valke');
arrT2 : array[1..6] of string = ('Lions','Pumas','Leopards','Western Province','Kavaliers','Eagles');
begin
Randomize;
sTeam1 := arrT1[Random(5)+1];
Randomize;
sTeam2 := arrT2[Random(5)+1];
lblT1Pred.Caption := (sTeam1 + ' predicted score :');
lblT2Pred.Caption := (sTeam2 + ' predicted score :');
rbTeam1.Caption := sTeam1;
rbTeam2.Caption := sTeam2;
end;
在第二张表格中,我有以下内容:

procedure TfrmAdminInput.FormCreate(Sender: TObject);
begin
rbT1.Caption := sTeam1;
rbT2.Caption := sTeam2;
end;
sTeam1和sTeam2是全局变量

现在在第四个表单中,我点击一个按钮开始预测下一场比赛-因此我需要选择另外两个随机团队,首先我想要创建重复的数组并使用以下代码,但是它给了我一个“未声明的标识符:lblT1Pred”的问题——这个问题对于lblT2Pred和第二个表单上的标签(rbT1.Caption和rbT2.Caption)以及表单1上的单选按钮标题是一样的。代码如下:

sTeam1 := arrT1[Random(5)+1];
sTeam2 := arrT2[Random(5)+1];
frmUserInput.lblT1Pred.Caption := (sTeam1 + ' predicted score :');
frmUserInput.lblT2Pred.caption := (sTeam2 + ' predicted score :');
frmUserInput.rbTeam1.Caption := sTeam1;
frmUserInput.rbTeam2.Caption := sTeam2;
frmAdminInput.rbT1.Caption := sTeam1;
frmAdminInput.rbT2.Caption := sTeam2;
表格1为frmUserInput,表格2为frmAdminInput,表格4为frmWinners


因此,为了修改我想做的是,通过点击表单4上的按钮来更改表单1和表单2上标签和单选按钮的标题(该按钮还将隐藏表单4并显示表单1)。

如果在Unit1中定义了名为Form1的全局变量,并且该表单具有名为Label1的标签,然后从另一个单元访问它,如下所示:

  • 将Unit1添加到另一个单元的uses子句中
  • 参考表格1中的标签。标签1
为了避免循环引用,您可能需要将Unit1添加到其他单元的实现部分的uses子句中


也就是说,我更希望表单提供一个公共方法来完成这项工作,而不是让所有人都来处理它的私有部分。

如果在Unit1中定义了一个名为Form1的全局变量,并且该表单有一个名为Label1的标签,那么您可以从另一个单元访问它,如下所示:

  • 将Unit1添加到另一个单元的uses子句中
  • 参考表格1中的标签。标签1
为了避免循环引用,您可能需要将Unit1添加到其他单元的实现部分的uses子句中

也就是说,我更希望表单提供一个公共方法来完成这项工作,而不是让所有人都来处理它的私有部分。

您确定错误不是“未声明的标识符:frmUserInput”?您确定错误不是“未声明的标识符:frmUserInput”?