ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

22-Logical Operators

Logical operators is similar to Boolean expressions that return a boolean result. These And, Or, AndAlso, OrElse, and Xor operators are called binary because they acquire two operands. But  there is one operator that is not binary and it is called unary that takes a single operand, an example of it is the Not operator.

 

Binary Operators:

It performs logical conjunction on two Boolean expression . For instance, if the expression is true and false the results is False ,if  the expression is true and true the results is True and if the expression is false or true the results is True.

example:

  1. Dim name As String = "Kenjie"
  2. Dim age As Integer = 12
  3. If name = "Kenjie" And age = 12 Then
  4. 'the statements return True
  5. End If
  6. If name = "Kenjie" Or age = 13 Then
  7. 'the statements return True
  8. End If
  9. If name = "Kenjie" And age = 13 Then
  10. 'the statements return False
  11. End If

 

Unary Operators :

It performs logical negation on a Boolean expression. For instance, if the expression is true the results is true and if the expression is false the results is False

example

  1. Dim name As String = "Kenjie"
  2. Dim age As Integer = 12
  3. If Not name = "Kenjie" Then
  4. 'the statements return False
  5. End If
  6.  
  7. If Not age = 13 Then
  8. 'the statements return True
  9. End If

 

 

 

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!