初学者。按照书上的说法试着声明变量,用type语句如下:
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
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
type
Tcolor=(red,blue);
var
c: Tcolor ;
c:=red;
end;
end.
怎么系统总是报错 Project1.dpr(5): Could not compile used unit 'Unit1.pas'?
或者你也可以简单的告诉我。type和var怎么用(我按照书上说的做不行)
谢谢!
我出现的错误是把type和var放在了begin end里面了是吗?
是的
谢谢!
谢谢啦。那个,能不能给我讲解一下啊?
追答TForm1 = class(TForm)
这也是定义了一个类,所以后面定义了一个对象var Form1: TForm1;
Tcolor=(red,blue);
类似的也定义了一个类型,可以直接使用。