这个delphi常量怎么写呢?

来源:百度知道 编辑:UC知道 时间:2024/05/25 16:43:11
为什么是错的呢?
procedure TForm1.Button1Click(Sender: TObject);
const
circlerate=3.14;
begin
circlerate=3.14;
showmessage:string ='这是为什么?';
end;
end.
提示:没有实际的参数?请高人回答?

procedure TForm1.Button1Click(Sender: TObject);
const
circlerate=3.14; //设定常量值
begin
circlerate=3.14; //常量值设定后不能再赋值,而且,赋值是:=而不是=
showmessage:string ='这是为什么?'; //显示字符串应该这样:ShowMessage('这是为什么?')
end;
end.
提示:没有实际的参数?请高人回答?

给你个小例子
procedure TForm1.Button1Click(Sender: TObject);
const
a=3;
var
b:Integer;
c:string;
begin
b:=4;
c:='计算a+b的值=';
ShowMessage(c+inttostr(a+b));
end;

procedure TForm1.Button1Click(Sender: TObject);
const
circlerate=3.14;
begin
showmessage('这是为什么?');
end;
end.