再问:如何判断variant类型的值是否为空?(100分)

  • 主题发起人 主题发起人 冰冷的雨
  • 开始时间 开始时间

冰冷的雨

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:<br>with DataSet do<br>&nbsp; if VarIsEmpty(DieldByName('iCode').Value) <br>&nbsp; &nbsp; or VarIsEmpty(DieldByName('cText').Value) then<br>&nbsp; begin<br>&nbsp; &nbsp; ShowMessage('请输入代码');<br>&nbsp; &nbsp; abort;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; ShowMessage(inttostr(FieldByName('iCode').Value)+' &nbsp;'<br>&nbsp; &nbsp; &nbsp; +FieldByName('iCode').Value;<br>为什么当cText没有内容时,两个ShowMessage都不执行,而iCode没有内容时会出错:Could not convert variant of type (Null) into<br>type (Integer)?
 
DieldByName('iCode').isNull 也可以判断
 
with DataSet do<br>&nbsp; if VarIsEmpty(FieldByName('iCode').Value) <br>&nbsp; &nbsp; or VarIsEmpty(FieldByName('cText').Value) <br>&nbsp; &nbsp; or (trim(FieldByName('cText').AsString)='') then<br>&nbsp; begin<br>&nbsp; &nbsp; ShowMessage('请输入代码');<br>&nbsp; &nbsp; abort;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; ShowMessage(inttostr(FieldByName('iCode').Value)+' &nbsp;'<br>&nbsp; &nbsp; &nbsp; +FieldByName('cText').AsString;
 
本问题属重复问题,不好意思
 
后退
顶部