小弟刚学Delphi才二天,按照书本上的做了一下,却不能运行,请哪位大大帮我一下。(20分)

J

jackfei

Unregistered / Unconfirmed
GUEST, unregistred user!
在窗口放一Label和一Timer,双击Timer添加以下代码:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label1.caption:='Hello world!' then
Label1.Caption:='你好 世界!'
else
label1.Caption:='Hello world!';
end;

end.

但按F9运行时,却提示“Type of expression must be BOOLEAN”,我该怎么办?
 
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label1.caption='Hello world!' then

Label1.Caption:='你好 世界!'
else
label1.Caption:='Hello world!';
end;
 
Type of expression must be BOOLEAN
表达式的类型必须为布尔型。
if label1.caption:='Hello world!' then
Label1.Caption:='你好 世界!'
^^你这儿打错咯
 
if ... then
的判断是 BOOLEAN 值,而 label1.caption:='Hello world!' 是一个
赋值语句。
 
:)真是有意思你上面的语句应该写成
if Label1.Caption=' Hello world!' then
Label1.Caption:='您好 世界'
‘:=’这应写成‘=’
 
:=是賦值
=都是比較
 
真的是新手,呵呵
 
多人接受答案了。
 
顶部