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
"If ... Else" Statement
"If ... ElseIf" Statement
"Select Case" Statements
Performs an operation only if the condition evaluates to True
Used when an action is either performed or not performed.
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.
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
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
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.
Entry only when a initial condition is met
Repeats for a specific number of times
VBScript Loop Statements
"For ... Next" Statements
"Do ... Loop" Statements
Favored because all the loop details are in the definition statement
Entry Condition Loop
Simplest form of the loop
Requires manual modification of the loop condition
Do ... Loop
Similar to the while loop.
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.
Assigning Values to Array Elements
Retrieving Values from Array Elements
Array - Types
Array – Fixed Size
All arrays are zero-based.
A(0) = 3 …. A(9) = 6
Array - Dynamic array
Use Dim statement to initialize the array without the size or the number of dimensions.
Subsequently use ReDim to determine the number of dimensions and the size of each dimension.
Use Preserve keyword to preserve the contents of the array.
ReDim Preserve MyArray(30)
Use Erase keyword to release the memory.
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.