# Guide to Game Development/The Programming Language/VB.NET/If Statement
## If statement

An 'if' statement can be used to check the value of a variable and compare it to something else. Here's a list of some comparison/conditional operators:
| Conditional Operator | Description |
| = | Is equal to |
| <> | Is not equal to |
| > | Is greater than |
| < | Is less than |
| >= | Is greater than or equal to |
| <= | Is less than or equal to |

### Example of an if-statement in use
#### First run of the program

Input:
Output:

#### Second run of the program

Input:
Output:

### Example of a greater than being used
#### First run of the program

Input:
Output:

#### Second run of the program

Input:
Output:

#### Third run of the program

Input:
Output:
Notice that if it was equal to 5, there was no output, to get an output for 5 as well the code could be either changed to > 4 or >= 5

## Else

This is to used to active when the if statement isn't true.

### Example of Else Statement

Example code:

#### First run of the program

Input:
Output:

#### Second run of the program

Input:
Output:

#### Third run of the program

Input:
Output:

## Else If

These can be used to check for other things other than the first if statement.

### Example of Else If statement
#### First run of the program

Input:
Output:

#### Second run of the program

Input:
Output:

#### Third run of the program

Input:
Output:

#### Forth run of the program

Input:
Output:
Notice that the first is accepted, but the second statement is still true, but it didn't run that piece of code, this is because with if statement it goes from top to bottom, when it finds one statement that is true, it doesn't bother checking others.
A way to make both active when they're both true would be to do this:

##### Example Input and Output for this new algorithm

Input:
Output:

### You can have many Else If statements in a row

Example:
Of course this is an inefficient way of coding, a better way would be to write:
However the code above doesn't allow for the else part, for this we'll need to learn about boolean logic operators as seen below.

## Boolean Logic Operators

There are 4 main boolean logic operators available: AND, OR and XOR, NOT. Boolean logical operators compare the two boolean statements either side of it and then convert them both into another boolean statement (With the exception of NOT which only affects the boolean statement after it). They are defined as such:
| Operator | Description | Truth table |
| And | Is only true if both the statements are true, else it's false. | Input to the LeftInput to the rightOutput FalseFalseFalse FalseTrueFalse TrueFalseFalse TrueTrueTrue |
| Or | Is true if either one of the statements are true, or if they are both true. Is only false when both are false. | Input to the LeftInput to the rightOutput FalseFalseFalse FalseTrueTrue TrueFalseTrue TrueTrueTrue |
| Xor | Is true when either one are true. Is false if they are both true, or if they are both false (Only true if they are different). | Input to the LeftInput to the rightOutput FalseFalseFalse FalseTrueTrue TrueFalseTrue TrueTrueFalse |
| Not | Inverts the boolean value of the statement that follows it. | Input to the rightOutput FalseTrue TrueFalse |