if else statements
The conditional statement IF-ELSE is using for check the conditions that we provided in the head of if statement and making decision based on that condition. The conditional statement examining the data using comparison operators as well as logical operators.vb.net
If [Condition] Then Statement Else Statement
if (condition) statement; else
If the given condition is true then the control goes to the body of if block , that is the program will execute the code within if block. If the condition is false then the control goes to next level , that is if you provide else block the program will execute the code block of else statement, otherwise the control goes to next line of code.
The else statement is optional , so yo can use if statement without else statement.vb.net
If [Condition] Then Statement
If you want to check more than one conditions then you can use else-if statement .vb.net
If [Condition] Then Statement ElseIf [Condition] Then Statement Else Statement
if (condition) statement; else if (condition) statement; else
The following ASP.NET program declare and initialize values to two numbers , num1 and num2 and then check which is greater using if statement.
Click the following links to see full source code