来看看我这缎代码有什么不对的吗?
前面声明了共有变量private
n: Integer;
str: string;
procedure fun(s:string);
下面是一个过程 按钮控件都调用这个过程
procedure TForm1.fun(s: string);
begin
case str of
'+' : begin
n:=n+strtoint(label1.Caption);
str:=s;
label1.Caption:=inttostr(n);
end
'-' : begin
n:=n-strtoint(label1.Caption);
str:=s;
label1.Caption:=inttostr(n);
end
'*' : begin
n:=n*strtoint(label1.Caption);
str:=s;
label1.Caption:=inttostr(n);
end
'/': begin
n:=n/strtoint(label1.Caption);
str:=s;
label1.Caption:=inttostr(n);
end
else
str:=s;
end;
end;
后知
CASE 选项值 OF.....
语句中,选项值不能为STRING类型,只能是整型,枚举类型等有序类型,
可能是你的书上错了,我就书上就是不能用STRING类型,要用STRTOINT()函数转换数据类型
迟来的回答,呵呵。。。。。 可以实现的方法就是给每个符号对应一个有序的数值。
页:
[1]
