VB.NET Control Statements

In VB.NET, control statements are statements that govern the execution of a program on the basis of the stated condition. It helps to determine if the situation is real or not. If the situation is correct, a single statement or block is made. In the regulatory statement, we will use the If, ‚Äč‚Äčthen, if not, If then Else-If and Select case statement.

We can describe more than one case that can be evaluated by the program having statements. For the true status of condition, the implementation of the statement is done in its way, and if the status of condition turns false, the execution of other statement is done.

VB.NET Control Statements

In the Statement-If, then, the situation can be a Boolean, logical, or relationship situation, and the statement may be individual or group of statements to be made when the situation is real.

If, then, another statement

Statement-If, we can add one or more statements when the situation is true, but when the statement analyzes the lie, it does nothing. So, here’s the If-Then-Else Statement. The IF-Then-Else statement states that if the situation should be created if the statement is false, we use the Else statement. The following If-Then-Else syntax statement on VB.NET follows:

  1. If (Boolean_expression) Then  
  2. ‘This statement will execute if the Boolean condition is true  
  3. Else  
  4. ‘Optional statement will execute if the Boolean condition is false  
  5. End If  

The diagram above represents that if the Boolean saying (condition) is true, if the statement if it will work, and if the Boolean saying is false, another code or statement will be used. Post this, the transfer of controls is done to the other statement, the statement must come after the If-Then-Else control statement.

VB.NET Statement If then ElseIf

In this, an option is given to select using one condition or the statement from multiple statements. Program starts from top to bottom, and checks each case of If. And if the situation is met, If block statements are executed. And if there are no real conditions, the last block is made. The following is the syntax of the If-Then-ElseIf Statement on VB.NET as follows:


  1. If(condition 1)Then  
  2.    ‘ Executes when condition 1 is true   
  3. ElseIf( condition 2)Then  
  4.    ‘ Executes when condition 2 is true   
  5. ElseIf( boolean_expression 3)Then  
  6.    ‘ Executes when the condition 3 is true   
  7. Else   
  8.    ‘ executes the default statement when none of the above conditions is true.   
  9. End If  
VB.NET Control Statements

The diagram above represents that if the Boolean saying (condition) is true, if the statement if it will work, and if the Boolean saying is false, another code or statement will be used. After that, the control transfer goes to the next statement, which is after the If-Then-Else control statement.

If this condition is true in the chart flow of if-else-if a statement, a statement is made within the block if. When the status of the condition is not true, the control is transferred to the next ElseIf condition to check whether the condition is the same. And if there are no similar conditions, another block is made.

Select Cases Statement

In the Select Case statements, several case statements are brought together to create a single case statement. The selected case statement uses a variable to check the equality in most cases or statements in the system. If the flexibility is matched by any test cases, that statement will be made. And if the situation is different from other cases, we use a default statement.

Using the selected case statement in the VB.NET program, you can replace the use of multiple If-Then-Else If statements from the system for better readability and ease of use.

VB.NET Control Statements

In Flowchart, the Select Case statement represents the first process test from top to bottom. If the expression or value is matched by the initial choice case, statement -1 is made another transfer of control to the next case to determine whether the expression is the same or not. Similarly, it checks all case statements selected for testing. In the absence of similar cases, an Else block statement will be made, and finally, the Selected Cases Statement will expire.

Selected Case VB.NET statements

In this, the Statement of Select Case is written into the other selected Case Statement.

Pin It on Pinterest

Share This