语句如下:
if StrToInt(REP.QRLabel24.Caption)<>StrToInt(REP.QRLabel28.Caption) then
ShowMessage('数据有误,请重试');编译不通过,错误提示
[Error] f_report.pas(84): Incompatible types: 'String' and 'Integer'

解决方案 »

  1.   

    Caption 中 有不是数字的字符
      

  2.   

    var
      s1,s2:string;
      s1:=REP.QRLabel24.Caption;
      s2:=..
     if StrToInt(s1) <>StrToInt(s2) then 
    ShowMessage('数据有误,请重试');  
      

  3.   

    function StrToInt(const S: string): Integer;//vcl中声明
    type TCaption = type WideString;//帮助中说明
      

  4.   

    缺省条件下:string=ansistring 
     widestring基于unicode
      

  5.   


    没道理。这行代码没问题的,一定是其他地方的问题。REP是个窗体吧?上下文贴点代码看看。
      

  6.   

    QRLabel24, QRLabel28这2个是控件??REP.QRLabel24.Caption 或 REP.QRLabel28.Caption 是不是string类型的?是不是搞错成Integer了?
      

  7.   

    语句如下: 
    if StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption) then 
    ShowMessage('数据有误,请重试'); 编译不通过,错误提示 
    [Error] f_report.pas(84): Incompatible types: 'String' and 'Integer'是不是REP.QRLabel24.Caption或REP.QRLabel28.Caption的Caption为String型啊?你在这一句if StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption) then 前
    把他们ShowMessage(REP.QRLabel24.Caption) ;
    ShowMessage(REP.QRLabel28.Caption) ;看看出来的是什么内容啊?
      

  8.   

    真的不行哦!!错误还是[Error] f_report.pas(84): Incompatible types: 'String' and 'Integer'
    整个就是点击TU_RP上的一的报表按钮,该按钮代码如下procedure TU_RP.BitBtn1Click(Sender: TObject);
    begin
      if  Trim(Memo1.Text)='' and StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption) then
      begin
        ShowMessage('数据有误,请重试');
      end
      else
      REP.QuickRep1.Preview;
    end;
      

  9.   

    要看看caption里什么字符串,设个断点看一下吧
      

  10.   

    procedure TU_RP.BitBtn1Click(Sender: TObject); 
    begin 
      if  (Trim(Memo1.Text)='') and (StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption)) then //<--记住加括号
      begin 
        ShowMessage('数据有误,请重试'); 
      end 
      else 
      REP.QuickRep1.Preview; 
    end;
      

  11.   

    if  Trim(Memo1.Text)='' and (StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption)) then 
       ...括号要加;  and 的 优先级高于 <> 按你的写法是先 Trim(Memo1.Text)='' and (StrToInt(REP.QRLabel24.Caption)  然后才  <>