' suppose we have 4 filters, which have just returned a true or false, in the variables a()
' we want to evaluate the expression 'a(0) and a(1) or a(2) and a(3) and so on...'
Dim res,res2 As Double
Dim ret As Boolean
Dim err,exp,msg, expOrig As String
' here we get the results of our filters and their logical operators
Dim a(4) As Boolean, op(4) As String
a=Array As Boolean (True,False,True,True)
op=Array As String ("","AND","OR","AND")
' we begin the evaluation
Eval.Initialize
exp="":expOrig=""
For k=0 To a.Length -1
Dim tempvar,tempOp As Char
tempvar=Chr(65+k)
If a(k)=True Then
Eval.SetGlobal (tempvar,1)
Else
Eval.SetGlobal (tempvar,0)
End If
Select op(k)
Case "AND"
tempOp="*"
Case "OR"
tempOp="+"
Case Else
tempOp=op(k)
End Select
exp=exp & tempOp & tempvar
expOrig=expOrig & " " & op(k) & " " & a(k)
Next
exp=exp.Trim
expOrig=expOrig.Trim
res = Eval.Evaluate(exp)
err = Eval.Error
If err = "" Then err = "No Error"
If res>0 Then ret=True Else ret=False
msg = expOrig & CRLF & exp & CRLF & " = " & ret
Msgbox(msg, err)