楚
楚辞
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:label1,label3, edit1, button;var Form1: TForm1; int1,int2:integer;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); begin if Trim(Edit1.Text) = '' thenbegin MessageBox(Handle, '请在文本框里输入结果', '系统提示', MB_ICONINFORMATION or MB_OK); Exit;end;begin tryif (StrToInt(edit1.Text)=(int1+int2)) thenbeginRandomize ;label1.Caption:=intTostr(int1)+'+'+intToStr(int2)+'=';end elsebeginlabel3.Caption:='输入正确,请计算下题';edit1.clear;end;exceptlabel3.Caption:='输入错误,请重新输入';edit1.clear;end;end; end;procedure TForm1.FormCreate(Sender: TObject);beginRandomize;int1:=random(10);int2:=random(10);label1.Caption:=intTostr(int1)+'+'+intToStr(int2)+'=';edit1.Text:='';end;