I would like to get your code thought and views on using conditional vs logical testing.
To test the conditions of truthness of all of the following variables, their currect status is as follows:
a= True b= True c= True d= True e= True
One could use as test as follows to ensure that they all are true:
- Method 1:
If a And b And c And d And e Then x = "Passed" Else x = "Failed"
- Metod 2:
If a = b = c = d = e Then x = "Passed" Else x = "Failed"
- Method 3:
If a Then If b Then If c Then If d Then If e Then x = "Passed" Else x = "Failed"
With all variables being “True”: Method 2 is the slowest and Method 3 using Condition is fastest.
If any of the variables states would be changed from True to False then Method 3 (Conditional) always wins by big margin.
I do tend to test 2 conditions or more for truthness using the AND logic (we all do, i guess). But isn’t quicker to do an “If If” statement.
Looking forward to your valuable feedback and input.