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:

First run of the program
Input: 5 Output: They have chose the number 5!

Second run of the program
Input: 4 Output:

First run of the program
Input: 8 Output: Their number was greater than 5!

Second run of the program
Input: 3 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: 8 Output: Their number is greater than or equal to 7.

Second run of the program
Input: 7 Output: Their number is greater than or equal to 7.

Third run of the program
Input: 6 Output: Their number is less than 7.

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

First run of the program
Input: 9 Output: 7 and more.

Second run of the program
Input: 7 Output: 7 and more.

Third run of the program
Input: 6 Output: Everything else (6 or less).

Forth run of the program
Input: 8 Output: Equal to 8. 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: 8 Output: Equal to 8. 7 and more.

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: