The IF-Then-Else Statement is telling what If condition to do when if the statement is false, it executes the Else statement. So, here comes the If-Then-Else Statement. The If-Then Statement can execute single or multiple statements when the condition is true, but when the expression evaluates to false, it does nothing.
And if the first number is greater than the other, the first statement is executed otherwise, the second statement will be executed. In the above program, we enter two numbers to find the greater number using the relational operator. Now compile and execute the above program by clicking on the Start or F5 button, it shows the following output: No2 = Console.ReadLine() ?read no2 from userĬonsole.WriteLine("First number is greater than second number")Ĭonsole.WriteLine("Second number is greater than First number")Ĭonsole.WriteLine("press any key to exit.") No1 = Console.ReadLine() ?read no1 from user The If-Then Statement is a control statement that defines one or more conditions, and if the particular condition is satisfied, it executes a piece of information or statements.Ĭonsole.WriteLine("Enter any two number:") VB.NET provides the following conditional or decision-making statements. The above diagram shows that if the defined condition is true, statement_1 will be executed, and if the condition is false, statement_2 will be executed. The following figure shows a common format of the decision control statements to validate and execute a statement: If the defined condition is true, the statement or block executes according to the condition, and if the condition is false, another statement is executed. We can define more than one condition to be evaluated by the program with statements. In the control statement, we will use if- Then, if Then Else, if Then ElseIf and the Select case statement. If the condition is true, a single or block of statement is executed. It is useful for determining whether a condition is true or not. In VB.NET, the control statements are the statements that controls the execution of the program on the basis of the specified condition.