Branching
Allows you to avoid running certain sections of your code
Code is only executed when a condition (or conditions) evaluate to True
Provides a single application the ability to react differently to different input values

Conditional Statements
“If” statement
Single-statement "If"
Multi-statement "If“
"If ... Else" Statement
"If ... ElseIf" Statement
"Select Case" Statements
If
Performs an operation only if the condition evaluates to True
Used when an action is either performed or not performed.
Syntax:
If…Else
Performs the If portion only if the condition evaluates to True and the Else portion otherwise.
Used in an either or scenario when an operation is always performed.
Syntax:

If…ElseIf
Only one section can be executed even if many conditions evaluate to True.
Used in a multiple choice scenario
Inclusion of the last Else is optional
Syntax:
Select
Used to choose between 1 of several discrete values for a variable.
Inclusion of Case Else is optional
Less powerful compared to the If statement
Syntax:
Loops
Loops
Allows you to repeat running certain sections of your code
Code executes when a condition (or conditions) evaluate to True
Be careful with Loops. They can result in infinite processing.
Forms
Entry Condition
Entry only when a initial condition is met
Iterated
Repeats for a specific number of times
VBScript Loop Statements
"For ... Next" Statements
"While" Statements
"Do ... Loop" Statements
For Loop
Iterated Loop
Favored because all the loop details are in the definition statement
Syntax:


While
Entry Condition Loop
Simplest form of the loop
Requires manual modification of the loop condition
Syntax:


Do ... Loop
Similar to the while loop.
Syntax:

Arrays
Arrays - Introduction
Collection of data elements of the same data type.
Each element in an array is associated with a unique index number.
A specific element in an array can be referred by the index number.
A number of built-in functions are provided to work with arrays.

Syntax:


Assigning Values to Array Elements


Retrieving Values from Array Elements


Array - Types
Two Types
Fixed-size array


Dynamic array
Array – Fixed Size
Example:
Dim A(10)
All arrays are zero-based.
Assignment:
A(0) = 3 …. A(9) = 6
Array - Dynamic array
Use Dim statement to initialize the array without the size or the number of dimensions.
Example
Dim MyArray()
Subsequently use ReDim to determine the number of dimensions and the size of each dimension.
Example
ReDim MyArray(25)

Use Preserve keyword to preserve the contents of the array.
Example
ReDim Preserve MyArray(30)
Use Erase keyword to release the memory.
Note:
There is no limit to the number of times you can resize. But making an array smaller than it was may lose the data in the eliminated elements.