统计表达式可以理解为是否的判断,就是:条件1是否成立 or 条件2是否成立 or 条件3是否成立 or ......
1=2是一种为了减少代码的取巧用法,因为1=2始终都是不成立的,所以:1=2 or 条件2是否成立 or 条件3是否成立 or ......
就等同于条件1不成立 or 条件2是否成立 or 条件3是否成立 or ......
如果不用1=2,可能就是这样的:
Dim Filter As String With e.Form.Controls("cmbProduct") If .Value IsNot Nothing Then Filter = "产品 = '" & .Value & "'" End If End With With e.Form.Controls("cmbCustomer") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " or " End If Filter = Filter & "客户 = '" & .Value & "'" End If End With |
如果使用1=2,就样
Dim Filter As String = "1=2" With e.Form.Controls("cmbProduct") If .Value IsNot Nothing Then Filter = " or 产品 = '" & .Value & "'" End If End With With e.Form.Controls("cmbCustomer") If .Value IsNot Nothing Then Filter = Filter & " or 客户 = '" & .Value & "'" End If End With |
不再需要一堆的这种判断
If Filter > "" Then
Filter = Filter & " or "
End If
[此贴子已经被作者于2020/4/6 16:09:15编辑过]