一只大猩猩 发表于 2021-4-19 14:09:02

新手入门,为什么新建的button会报错呢?

unit Unit3;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
TForm3 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure ButtonClick(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Edit3Change(Sender: TObject);

private
    { Private declarations }
public
    { Public declarations }
end;

var
Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
Label1.Caption:= '+' ;
Edit3.Text:= FloattoStr(StrToFloat(Edit1.Text) + StrToFloat(Edit2.Text) );
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
   Label1.Caption:= '-'   ;
   Edit3.Text:= FloattoStr(StrToFloat(Edit1.Text) - StrToFloat(Edit2.Text) );
end;

procedure TForm3.Button3Click(Sender: TObject);
begin
Label1.Caption:= '*'   ;
Edit3.Text:= FloattoStr(StrToFloat(Edit1.Text) * StrToFloat(Edit2.Text) );
end;

procedure TForm3.Button4Click(Sender: TObject);
begin
   Label1.Caption:= '/'   ;
   Edit3.Text:= FloattoStr(StrToFloat(Edit1.Text) / StrToFloat(Edit2.Text) );
end;

procedure TForm3.ButtonClick(Sender: TObject);
begin
   Label1.Caption:= 'not'   ;
   Edit3.Text:= IntToStr( not StrToInt(Edit2.Text) );
   Edit3.Text:= IntToStr( not StrToInt(Edit1.Text) );
end;


procedure TForm3.Edit1Change(Sender: TObject);
begin
edit1.Text:= ' '
end;

procedure TForm3.Edit2Change(Sender: TObject);
begin
   edit2.Text:= ' '
end;

procedure TForm3.Edit3Change(Sender: TObject);
begin
   edit3.Text:= ' '
end;

end.







最上面的button6-10全部报错了。刚刚对照着视频操作,莫名其妙。求大佬解释下。

心驰神往 发表于 2021-4-20 08:08:32

button4后面是不是button5啊

一只大猩猩 发表于 2021-4-20 10:47:40

心驰神往 发表于 2021-4-20 08:08
button4后面是不是button5啊

还是报错呢。

心驰神往 发表于 2021-4-23 08:00:19

一只大猩猩 发表于 2021-4-20 10:47
还是报错呢。

能上传下报错截图吗

心驰神往 发表于 2021-4-23 08:01:29

你的button6-10上面有buttonclick事件,但你下面没实现,所以报错
页: [1]
查看完整版本: 新手入门,为什么新建的button会报错呢?