For example, when a continuous judgment is made, even if the first one does not meet the criteria, the latter will still be counted. It is important to remember that unless all of your functions are necessary, it will result in less efficiency.
Code reduction does not necessarily improve efficiency, for IIF and continuous judgment, it seems that many people do not know that FUNCA,FUNCB,FUNCC will execute
The code below, interested can try to try or whether also like and
Option ExplicitPrivate SubCommand1_Click ()Print "Continuous Judgment------------------------" IfFunca andFuncb andFuncc Then Print ">>> OK"&vbCrLfElse Print ">>> NO"&vbCrLfEnd If Print "Nested judgment------------------------" IfFunca Then IfFuncb Then IfFuncc Then Print ">>> OK"&vbCrLfExit Sub End If End If End If Print ">>> NO"&vbCrLfPrint "IIF Judge------------------------" If IIf(FUNCB, FUNCC, Funca) Then Print ">>> OK"&vbCrLfElse Print ">>> NO"&vbCrLfEnd IfEnd SubPrivate FunctionFunca () as Boolean Print "run over Funca"Funca=FalseEnd FunctionPrivate FunctionFUNCB () as Boolean Print "run over FUNCB"FUNCB=TrueEnd FunctionPrivate FunctionFUNCC () as Boolean Print "run over FUNCC"FUNCC=TrueEnd Function
A description of the logic of judgment in VB