The unit file is the most important file in the Delphi program, which contains the most important source code in the program, whether the event handling process of the form and component or a separate source code is saved in the unit file. For beginners, Delphi's unit files are more complicated. Here, the unit file of Delphi5 will be described. Unit files are divided into form files and form files without form files. Whenever the user creates a new form in the project, for example using the "File | New Form" or Acceleration button, Delphi will automatically create a corresponding unit file. If the user needs a form-free unit file, you should use the "File | New Unit" menu command or add a unit file to the project manager. It can be said that each form corresponds to a unit, but in turn, it is not necessarily true. When you create a new application, only one unit file Unit1 and a corresponding form FORM1. Here is a typical unit file structure: Unit unit1; // Unit name interface // Interface part Uses // During this unit, the units access to each unit Windows, Messages, Sysutils, Classes, Graphics, Controls , Forms, Dialogs, // Standard Unit Unit2, Unit3; // User Custom Unit Type TFORM1 = Class (TFORM) // Stateing a new form class Label1: TLABEL; // The component on the form is declared as a new Object class Button1: TButton; ScrollBar1: TScrollBar; RadioButton1: TRadioButton; ComboBox1: TComboBox; procedure Button1Click (Sender: TObject); // all events is declared as a method of procedure ComboBox1Change new class (Sender: TObject); procedure Label1Click (Sender: TObject); procedure RadioButton1Click (Sender: TObject); private // declare private {private declarations} public // declare public {public declarations} end; var Form1: TForm1; // declare a form object implementation // implemented Some uses Unit4; {$ r * .dfm} end. The USES clause at the initial (interface part) begins with each unit used by this unit, where there is a system standard unit, we can also add a custom unit. . Then define a new form TFORM1, all components on the form are declared as an object in the new class, and is the Published type. All event processing processes are also stated in the Published type, so that the properties of the components can be modified or changed in the design phase. Then there is a new form object of a new form, the object name, is the Name property of the form. Implementation contains execution code and other implicit declarations. A reference between different units can use the USES statement. For example, if you need to reference the variables and objects in Unit2 in Unit1, you can add a single-name unit2 in the UNEs statement of the Interface section of Unit1. But one thing to note is that the loop reference is not allowed in Delphi. So we can't add references to Unit1 in the USES statement of Unit2's Interface section.