Search code examples
delphidelphi-7

File not found "Form2.dcu"


I can't resolve this problem, anyone can help?

Unit 1 code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Form2; //error here

type
  TForm1 = class(TForm)

and here is Unit 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.

yes I created Form2 made it's caption "Cestitke!" and kept name as Form2

And I would like to know how to fix it in future, thanks


Solution

  • I think you are misunderstanding the error.

    Your Uses is

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Form2; //error here
    

    but to access Form2, what you need to include in this list is not the name of the form, but instead the name of the unit in which it is declared, i.e. Unit2.

    So, your Uses list should read:

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Unit2; 
    

    But usually in a situation like this, it is sufficient to include Unit2 in a Uses list in the implementation section of Unit1.