找不到文件 "Form2.dcu"
File not found "Form2.dcu"
我无法解决这个问题,有人可以帮忙吗?
单元 1 代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Form2; //error here
type
TForm1 = class(TForm)
这是第 2 单元
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
CESTITAMO: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Rezultat11: TLabel;
REZULTAT21: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
end.
是的,我创建了 Form2,为其添加了标题 "Cestitke!",并将名称保留为 Form2
而且我想知道以后如何修复它,谢谢
没有单位Form2.pas。在您的 uses 子句中将 Form2 替换为 Unit2。
我认为你误解了这个错误。
您的用途是
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Form2; //error here
但是要访问 Form2,您需要在此列表中包括的是 而不是 表单的名称,而是声明它的单元的名称,即Unit2
.
因此,您的使用列表应为:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Unit2;
但通常在这种情况下,在 Unit1 的实现部分的 Uses
列表中包含 Unit2
就足够了。
从 uses 中删除“, Form2”,并将 "uses Unit2;" 添加到 implementation 部分。这是一个工作示例:
unit Unit1;
interface
{uses //Delphi 10.2
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;}
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.ShowModal; //or Form2.Show;
end;
end.
我无法解决这个问题,有人可以帮忙吗?
单元 1 代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Form2; //error here
type
TForm1 = class(TForm)
这是第 2 单元
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
CESTITAMO: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Rezultat11: TLabel;
REZULTAT21: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
end.
是的,我创建了 Form2,为其添加了标题 "Cestitke!",并将名称保留为 Form2
而且我想知道以后如何修复它,谢谢
没有单位Form2.pas。在您的 uses 子句中将 Form2 替换为 Unit2。
我认为你误解了这个错误。
您的用途是
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Form2; //error here
但是要访问 Form2,您需要在此列表中包括的是 而不是 表单的名称,而是声明它的单元的名称,即Unit2
.
因此,您的使用列表应为:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Unit2;
但通常在这种情况下,在 Unit1 的实现部分的 Uses
列表中包含 Unit2
就足够了。
从 uses 中删除“, Form2”,并将 "uses Unit2;" 添加到 implementation 部分。这是一个工作示例:
unit Unit1;
interface
{uses //Delphi 10.2
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;}
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.ShowModal; //or Form2.Show;
end;
end.