Compound comparison Visual Basic 6.0 – 10th tutorial

Last Updated on

Compound Comparison and Conditional Statements

To compare more then one condition or we have to use multi conditional structure is called Compound Comparison. Its used to execute set of statements by testing many conditions.

As we learnt about extended if then else structure in our previous lesson here is almost same thing but we can say it’s little bit more advanced and also complicated.

Or we can say here is something to decision making in our program logic. We can face many conditions at same time and have to handle them using few logical operators.

While using if statements we can handle comparisons but using compound comparison it would be more easy to program even it will shorten our source code along with more functionality.

We will better understand it when we will use it in our realy projects. Dont worry in next lessons we will create a complete project to be expert in programming world. for now we will discuss main Three logical operators which we use in compound comparison.

We use logical operators for multi conditional structure. There are main three logical operators we will discuss in this tutorial.

 

  1. AND operator
  2. OR operator
  3. NOT operator

 

[AdSense-A]

 

AND operator

 

AND operator is used to check or compare two conditions. It returns TRUE if both conditions are true and returns FALSE if any one is False condition from both.

Example

Compound comparison statement example

OR operator

The OR operator is also used to compare two conditions. It returns TRUE if one of both conditions is true. And returns FALSE if both conditions are false.

READ  Visual Basic user interface and IDE 2nd tutorial

Example

Compound comparison statement example

NOT operator

Its very useful and mostly used in programming. NOT operator is used to reverse the output of any comparison. It will return true if the result of condition is false and if the result is true it returns false.

 

[AdSense-B]