Edit : this code is evil ; I simply added this answer to indicate that this is possible.
Another case would be to use or in evaluating expressions that perform some kind of side effect that should happen:
Sub DoSomething() Dim succeeded As Boolean succeeded = FirstThing() Or SecondThing() Or ThirdThing() If succeeded Then ' Do something here End If End Sub
In this case, FirstThing, SecondThing, and ThirdThing are methods that should be executed as a whole, regardless of whether any of them fail or not, when the success value is accumulated. If you used OrElse, then if FirstThing or SecondThing failed, then the operations underlying the failure method will not be performed.
Erik forbes
source share