hakeの日記

Windows環境でプログラミングの勉強をしています。

EXCEL VBAメモ - 論理演算子評価

論理演算は常に演算子の両側を評価する。(最適化しない)

Sub foo()
    If t1() Or t2() Then
        MsgBox "1"
    Else
        MsgBox "2"
    End If
    If f1() And f2() Then
        MsgBox "3"
    Else
        MsgBox "4"
    End If
    
End Sub


Function t1() As Boolean
    MsgBox "exec t1()"
    t1 = True
End Function
Function t2() As Boolean
    MsgBox "exec t2()"
    t2 = True
End Function
Function f1() As Boolean
    MsgBox "exec f1()"
    f1 = False
End Function
Function f2() As Boolean
    MsgBox "exec f2()"
    f2 = False
End Function