if a = b then 
^^^^^^^
elseif a <> b and a = c then
^^^^^^
end if这个分支结构两个条件下做的操作是一样的,而且第二个条件是第一个条件的对立面。请问是不是可以把两个条件写在一块啊?怎么写呢?

解决方案 »

  1.   

    if a = c then 
    ^^^^^^^
    'elseif a <> b and a = c then
    '^^^^^^
    end if
      

  2.   

    if (a=b) or (a<>b and a=c) then  ??
      

  3.   

    象这样的情况怎么办?用OR写到一起是会出问题的:
    If IsNumeric(Trim(Me.text1.text)) = False ThenElseIf CStr(CInt(Trim(Me.text1.text))) <> Trim(Me.text1.text) ThenEnd If
      

  4.   

    if (a=b) or ( a=c and b<>c)  then
    ...
    end if
    If IsNumeric(Trim(Me.text1.text)) = true Then
        if CStr(CInt(Trim(Me.text1.text))) <> Trim(Me.text1.text) Then
            .....
        end if
    end if
      

  5.   

    楼上有没有看清我的代码呢?第一个条件是IsNumeric(Trim(Me.text1.text)) = false,第二个条件是判断当IsNumeric(Trim(Me.text1.text)) = true时,是不是整数。这两个条件如果用or连接在一起是会出错的.你的写法基本上误解了我的意思了!
      

  6.   

    用一个标志变量
    Dim bFlag As BooleanIf IsNumeric(Trim(Me.text1.text)) = False Then
      bFlag = True
    ElseIf CStr(CInt(Trim(Me.text1.text))) <> Trim(Me.text1.text) Then
      bFlag = True
    Else
      bFlag = False
    End IfIf bFlag Then
      '执行操作
    End If
      

  7.   

    if a = b or a = c then
    ^^^^^^
    end if这样还不是一样
      

  8.   

    if a = b then 
    ^^^^^^^
    else
      if  a = c then
       
     ^^^^^^
       end if
    end if
      

  9.   

    呵呵,没有那么复杂吧。最简单的形式,就是 adao2003(阿刀) 所言:if a = b or a = c then
    ^^^^^^
    end if
      

  10.   

    if a = b or a = c then