语句如下:
if StrToInt(REP.QRLabel24.Caption)<>StrToInt(REP.QRLabel28.Caption) then
ShowMessage('数据有误,请重试');编译不通过,错误提示
[Error] f_report.pas(84): Incompatible types: 'String' and 'Integer'
if StrToInt(REP.QRLabel24.Caption)<>StrToInt(REP.QRLabel28.Caption) then
ShowMessage('数据有误,请重试');编译不通过,错误提示
[Error] f_report.pas(84): Incompatible types: 'String' and 'Integer'
s1,s2:string;
s1:=REP.QRLabel24.Caption;
s2:=..
if StrToInt(s1) <>StrToInt(s2) then
ShowMessage('数据有误,请重试');
type TCaption = type WideString;//帮助中说明
widestring基于unicode
没道理。这行代码没问题的,一定是其他地方的问题。REP是个窗体吧?上下文贴点代码看看。
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) ;看看出来的是什么内容啊?
整个就是点击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;
begin
if (Trim(Memo1.Text)='') and (StrToInt(REP.QRLabel24.Caption) <>StrToInt(REP.QRLabel28.Caption)) then //<--记住加括号
begin
ShowMessage('数据有误,请重试');
end
else
REP.QuickRep1.Preview;
end;
...括号要加; and 的 优先级高于 <> 按你的写法是先 Trim(Memo1.Text)='' and (StrToInt(REP.QRLabel24.Caption) 然后才 <>