if还要有括号等等,看见代码就有点头大了。这个例子我貌似做了。unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
lbl4: TLabel;
edt1: TEdit;
btn1: TButton;
btn2: TButton;
procedure FormCreate(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var s1:Integer;
s2:Integer;
result:Integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
s1:=Random(100);
s2:=Random(100);
s1:=Random(100);
s2:=Random(100);
lbl1.Caption:=IntToStr(s1);
lbl2.Caption:=IntToStr(s2);
result:=s1+s2;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if(StrToInt(edt1.Text)=result)then
MessageBox(Handle,'恭喜你,回答正确','程序提示',MB_OKCANCEL)
else
ShowMessage('回答错误,幼儿园没毕业');
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
s1:=Random(100);
s2:=Random(100);
s1:=Random(100);
s2:=Random(100);
lbl1.Caption:=IntToStr(s1);
lbl2.Caption:=IntToStr(s2);
result:=s1+s2;
end;
end.
|