新建模块的格式 -
新建模块的格式 - 在线等
自定义的函数,不想写在Form1的pas文件里,所以新建了一个Unit,格式如下
unit Unit2;
interface
implementation
end.
请问怎样定义过程和函数,格式怎么写?
新手入门。不胜感激!
^_^
------解决方案--------------------
在
interface
implementation之间定义函数,然后在
implementation
end.写函数体
------解决方案--------------------
Unit2的内容
自定义的函数,不想写在Form1的pas文件里,所以新建了一个Unit,格式如下
unit Unit2;
interface
implementation
end.
请问怎样定义过程和函数,格式怎么写?
新手入门。不胜感激!
^_^
------解决方案--------------------
在
interface
implementation之间定义函数,然后在
implementation
end.写函数体
------解决方案--------------------
Unit2的内容
- Delphi(Pascal) code
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; procedure SetFormCaption(aForm: TForm; aCaption: string); implementation procedure SetFormCaption(aForm: TForm; aCaption: string); begin aForm.Caption := aCaption; end; end.
------解决方案--------------------
Unit1来调用
- Delphi(Pascal) code
unit Unit1; interface 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 uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin SetFormCaption(Self, '窗口标题'); end; end.