When the VB IF statement performs an "And" condition check, it needs to check (execute) each sub-condition expression before determining whether the condition is true. But in other languages, if the first sub-condition does not hold, the remaining condition judgment will not be executed. Why is the condition judgment of VB6 so inefficient?
Code:Private Sub TestVBConditonExpression() If Condition_01() And Condition_02() And Condition_03() And Condition_04() Then MsgBox "Conditon succeeded !" Else MsgBox "Conditon failed !" End If End Sub Private Function Condition_01() As Boolean MsgBox "Condition 01 -- Failed" End Function Private Function Condition_02() As Boolean MsgBox "Condition 02 -- Failed" End Function Private Function Condition_03() As Boolean MsgBox "Condition 03 -- Failed" End Function Private Function Condition_04() As Boolean MsgBox "Condition 04 -- Failed" End Function Private Sub Form_Click() TestVBConditonExpression End Sub




Reply With Quote