Answers

Question and Answer:

  Home  ASP.NET 2.0

⟩ What is difference between OR and ORElse?

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.

 129 views

More Questions for you: