delphi if 语句的写法,我遇到了一个问题就是:
if(a.text<>'')and(length(b.text)=15)or(length(b.text)=18)and(c.text<>'')and(d.text<>'')then
我想让b的条件等于18或15中任意一个条件成立就可以,起他的条件同时都成立.也就是a,b,c,d同时成立.我怎么做?
我写成这样子有问题
if(a.text<>'')and((length(b.text)=15)or(length(b.text)=18))and(c.text<>''))and(d.text<>'')then

解决方案 »

  1.   

    if (Length(b.Text)=15) OR (Length(b.Text)=18) OR (Trim(a.Text)<>'' AND Trim(b.Text)<>'' AND Trim(c.Text)<>'' AND Trim(d.Text)<>'') then 
      

  2.   

    if ((18 = Length(b.Text)) or (15 = Length(b.text))) and
       ('' <> a.Text) and ('' <> c.text) and ('' <> d.text) then没发现什么问题。设置个断点看看哪里不对?
      

  3.   

    我写错了应该是
    if(b.text <>'')and(length(b.text)=15)or(length(b.text)=18)and(c.text <>'')and(d.text <>'')then 
    要b,c,d都成立,b有两个长度的限制条件,两个条件满足一个长度就可以,而且b,c,d都不能为空.
      

  4.   

    if (length(b.text) in [15.18]) or ((a.text <>'')and(c.text <>'')and(d.text <>''))then
      

  5.   

    len : Integer;blen := Length(b);if (a <> '') and (blen in [15,18]) and (b <> '') and (c <> '') then
    begin
      //条件成立
    end;
      

  6.   

    if(a.text <>'')and((length(b.text)=15)or(length(b.text)=18))and(c.text <>''))and(d.text <>'')then