|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Delphi 新手 用Delphi7跟着视频学习 程序编译成功之后 怎么动不动就会提示' xx is not a valid integer value' 呢? 明明就是个数字啊?
代码在这:(<[08]结构化程序设计01(下) - 零基础入门学习>里的验证那块的);
求救阿!!!!!!!好困惑!!英语不行!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
procedure Edit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
dat: Integer;
{$R *.dfm}
procedure TForm1.Edit1Click(Sender: TObject);
begin
Edit1.Text:= ' ';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
Label1.Caption:=IntToStr(Random(100));
Label2.Caption:=IntToStr(Random(100));
dat:=(StrToInt(Label1.Caption)+ StrToInt(Label2.Caption));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Randomize;
Label1.Caption:=IntToStr(Random(100));
Label2.Caption:=IntToStr(Random(100));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
temp: Integer;
begin
temp:= StrToInt(Edit1.Text);
if (temp=dat) then
ShowMessage('回答正确,电脑即将爆炸!')
else
ShowMessage('回答错误!');
end;
end.
错误后提示如下:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
|
|