我写的一段代码
procedure TForm1.Button1Click(Sender: TObject);
begin
x:=random(100);
edit1.Text :=inttostr(x);
end;
提示random后面应该用‘.’却出现了‘(’
第一次这么写都没有问题,想要生成exe后就出现上述错误

解决方案 »

  1.   

    x是在前面定义的integer,没有copy下来
      

  2.   

    unit random;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Label1: TLabel;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
       var
       x:integer;
       y:integer;
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    x:=random(100);
    edit1.Text :=inttostr(x);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    y:=random(100);
    edit2.Text :=inttostr(y);
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
    edit3.Text :=inttostr(x+y);
    end;procedure TForm1.Button4Click(Sender: TObject);
    begin
    edit3.Text :=inttostr(x*y);
    end;end.
      

  3.   

    如果还有疑问,请看这个帖子:
    http://topic.csdn.net/u/20100430/11/734690ad-4815-490b-bc1f-0882fd36889a.html?64566
      

  4.   

    也恭喜楼主 复制到D2010中 编译无任何错误提示
    OK
      

  5.   

    其他代码没什么问题,可能出问题的就是unit random;
    你的单元名称不要用函数名称,改个别的试试,看看还有问题没
      

  6.   

    你使用Random随机函数前
    先要Randomize;初始化随机原子