Tuesday, April 13, 2010

VB Scripting - Branching Statements

Previous11121314151617181920Next

What is Branching and types of Branching Statements?


Branching Statements in VB Scripting provides a user with a choice to execute certain piece of code based on the condition. This would help us to validate different conditions for one expression.


In general to say that the program or code has to make a decision based on a condition when a user gives a input or based on some parameters or values the decision has to be made then branching statements plays a vital role.

For example take this scenario of giving different grades to a student based on the percentage. For one student you can assign the marks to different variables and based on the average you can branch out your code and give the grade but imagine if you have to run it for more that one student then manually you have to go into the code and change for every student and save and run.

Branching Statements helps you in making the code decide the grade based on the conditions you give in the code once and ask the user to enter the marks for each student. Using these branching statements you can branch out your code to different conditions.

Basically there are three types of Branching Statements

1. If Else
2. If Elseif
3. Switch Case


Out of these the popular branching or conditional statement used is the If Else, Endif

Else and Elseif are used to branch out different conditions.

Previous11121314151617181920Next

1 comment:

Post a Comment