Results 1 to 34 of 34

Thread: [RESOLVED] Why are VB6 IF-expressions so inefficient?

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Resolved [RESOLVED] Why are VB6 IF-expressions so inefficient?

    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
    Last edited by dreammanor; Feb 27th, 2020 at 01:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width