As you may know, we can do a bitwise comparison for criteria or flags.
This works well if all criteria are required; so if we required 'a, b and d', we can ask thus:
But suppose we wanted to require '(either a or b) and d'? It surely could expressed as thus:
But the goal is to make the criteria easy to set up so we can just enter a value and somehow know that only either one of a given pair is required so instead of a lengthy If and And/Ors, we can do just this:
Is it possible to express the optional requirement in a bitwise comparison, or is there a better approach that will make it easy to alter the criteria required for a given context?
I thought about assigning multiple acceptable values for a given criteria from a lookup table so if we wanted to express '(a or b) and d', we can have two rows of "a Or d" and "a Or b", but that requires careful maintenance of all possible values and requires checking all possible combinations every time.
Also considered using a extra bit as a switch to indicate "either this or that" or "that and this" but felt too restrictive and a bigger headache.
I also can't assign same values to both a and b because for a different set criteria, it could be '(b or c) and d' while another criteria could be 'a and b and c and d'.
So... suggestions or ideas are welcome.
This works well if all criteria are required; so if we required 'a, b and d', we can ask thus:
Code:
If (MyCriteria And a) And _
(MyCriteria And b) And _
(MyCriteria and d) Then
'.... Criteria passed
Else
'.... Criteria wasn't satisifed
End If
But suppose we wanted to require '(either a or b) and d'? It surely could expressed as thus:
Code:
If (MyCriteria And a) Or _
(MyCriteria And b) And _
(MyCriteria And d) Then
'.... Criteria passed
Else
'.... Criteria wasn't satisifed
End If
But the goal is to make the criteria easy to set up so we can just enter a value and somehow know that only either one of a given pair is required so instead of a lengthy If and And/Ors, we can do just this:
Code:
If MyCriteria And ConstantValue Then
Is it possible to express the optional requirement in a bitwise comparison, or is there a better approach that will make it easy to alter the criteria required for a given context?
I thought about assigning multiple acceptable values for a given criteria from a lookup table so if we wanted to express '(a or b) and d', we can have two rows of "a Or d" and "a Or b", but that requires careful maintenance of all possible values and requires checking all possible combinations every time.
Also considered using a extra bit as a switch to indicate "either this or that" or "that and this" but felt too restrictive and a bigger headache.
I also can't assign same values to both a and b because for a different set criteria, it could be '(b or c) and d' while another criteria could be 'a and b and c and d'.
So... suggestions or ideas are welcome.