Public Function CalculateThisRule(TempRule As String) As Boolean    If InStr(TempRule, ">") <> 0 Or InStr(TempRule, "<") <> 0 Then
        CalculateThisRule = CalGreaterAndLess(TempRule)
    Else
        If UCase(Trim(EquValue(TempRule))) = "TRUE" Then
            CalculateThisRule = True
        Else
            CalculateThisRule = False
        End If
    End If
    
End Function一个ERP项目中BOM表中的一段

解决方案 »

  1.   

    Public Function CalculateThisRule(TempRule As String) As Boolean     '判断">","<"符号是否在TempRule里面,如果是,执行:CalculateThisRule = CalGreaterAndLess(TempRule) 
        '否则判断,UCase(Trim(EquValue(TempRule))) = "TRUE"成立否,如果成立函数返回true,否则返回false    If InStr(TempRule, ">") <> 0 Or InStr(TempRule, " <") <> 0 Then 
            CalculateThisRule = CalGreaterAndLess(TempRule) 
        Else        
            If UCase(Trim(EquValue(TempRule))) = "TRUE" Then 
                CalculateThisRule = True 
            Else 
                CalculateThisRule = False 
            End If 
        End If 
        
    End Function 
      

  2.   

    Public Function CalculateThisRule(TempRule As String) As Boolean     If InStr(TempRule, ">") <> 0 Or InStr(TempRule, " <") <> 0 Then '如果 TempRule 中有大于号或小于号
            CalculateThisRule = CalGreaterAndLess(TempRule)             '调用 CalGreaterAndLess 函数
        Else 
            If UCase(Trim(EquValue(TempRule))) = "TRUE" Then            '如果 TempRule = “TRUE" 或 ”true"
                CalculateThisRule = True                                '直接返回 True (-1)
            Else                                                        '否则
                CalculateThisRule = False                               '直接返回 False (0)
            End If 
        End If 
        
    End Function