What is difference between OR and ORElse?

Showing Answers 1 - 1 of 1 Answers

ORELSE - Either of the two expressions is true. If the first expression is True, the second is not evaluated. - ex. are from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/valrfOrElseOperator.asp

Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Boolean
myCheck = A > B OrElse B > C   ' True. Second expression is not evaluated.
myCheck = B > A OrElse B > C   ' True. Second expression is evaluated.
myCheck = B > A OrElse C > B   ' False.

If MyFunction(5) = True OrElse MyOtherFunction(4) = True Then
' If MyFunction(5) is True, MyOtherFunction(4) is not called.
   ' Insert code to be executed.
End If

ANDALSO -

Instead of doing thisIf(Function1() And Function2()) ThenDo thisIf(Function1() AndAlso Function2()) ThenThe first code will evaluate the result of Function2(), even if Function1() returned false.The second will only evaluate Function2() if Function1() returned true.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions