procedure TForm1.Button1Click(Sender: TObject);
var w,1x:real;
begin
   w:=edit1.text;
   if w<=50 then
     1x=0.25*w
   else
   if w<=100 then
     1x:=0.25*50+0.35*(w-50)
   else
     1x:=0.25*50+0.35*50+0.45*(w-50)
     label2.Caption:=format('y的值为:%8.2f',[1x]);
  end;
end;

解决方案 »

  1.   

    改错啊
    这么多错误!!!
    1、变量错了
    2、不是VB了,字符要转换成实数
    3、if  else结构错了
    4、缺分号
    5、是VB转过来的吧
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      w, x1: real;
    begin
      w:= StrToFloat(edit1.text);  if w <= round(50) then
        x1:= 0.25 * w
      else if w <= 100 then
        x1:= 0.25 * 50 + 0.35*(w-50)
      else
        x1:= 0.25 * 50 + 0.35*50 + 0.45 *(w-50);  Label2.Caption:= Format('y的值为:%8.2f',[x1]);
    end;
    //delphi 7下测试OK