VBScript Syllabus, VBScript Syntax, Coding Conventions, Variables, Constants, Operators, Functions, Control Flow, and Automation Object Models.
VBScript Syllabus for Beginners
1. Adding Comments
Purpose of Comments: To make the code readable and to make the code disable from Execution.
2. Data Types
No Data type specification in VBScript, VBScript considers data subtypes based on usage of the Data, and using VarType function user can check the data subtypes.
3. Varaibles
VBScript supports Explicit and Implict Declaratio of Variables
a) Constants
Built-in
User-defined
b) Variables
Scalar Variables
Array variables
* Dictionary object is equivalent to Hash variables/ Associated Arrays in Perl Script.
4. VBScript Operators
Categories of Operators
a. Arithmetic operators
b. Comparison operators
c. Logical operators
Note: Concatenation operators (Part of Arithmetic operators)
5. Control Flow – Decision Making/Conditional Statements
a. Types of conditional statements
i. If statement
ii. Select Case statement
b. Types of conditions
i. Single condition
ii. Compound condition
iii. Nested condition
c. Usage of Conditional statements
i. Execute a statement when the condition is true/simple if
ii. Execute a block of statements when condition True.
iii. Execute a block of statements when condition True, otherwise execute another block of statements.
iv. Decide among several alternates (Elseif)
v. Execute a block of statements when more than one condition is True (Nested If)
vi. Decide among several alternates (Using select Case)
6. Control Flow – Loop Statements
Four Loops Structures in VBScript
a. For…Next
b. While…Wend
c. Do While / Until…Loop
d. For Each…Next
Note: Using Exit Statement we can terminate the loops. We can insert Loop statements within conditions and vice versa.
7. VBScript Functions
The function is a Reusable code, whenever we want to execute the same operations multiple times then we prefer functions.
Types of functions
a. Built-in Functions
i. Array Functions
ii. String functions
iii. Date & Time functions
iv. Conversion functions
v. I/O Functions
vi. Math Functions
vii. Miscellaneous functions
b. User-defined Functions
i. Sub Procedures
Public, Private – Access control
Internal, External – Usage
ii. Function Procedures
Public, Private – Access control
Internal, External – Usage
8. Coding conventions
Writing comments
Naming conventions etc…
ex:
Dim num, city, Fso ‘Without standards
Dim intNum, strCity, objFso -With naming standards
9. File System Operations
> What is Computer File System?
> Examples for File System Operations
> How end-user performs File System Operations
> How to perform automatic File System Operations
Using File System Object we can perform automatic File System Operations
Class value for creating File System Object – (“Scripting.FileSystemObject”)
Set Variable = CreateObject(“Scripting.FileSystemObject”)
Set is VBScript statement
CreateObject is Built function
10. Excel Application Operations
Excel Application Object:
It is used to perform operations on Excel Application/Excel files
Class Value for creating Excel Application object – (“Excel.Application”)
11. Word Application operations
Word Application Object
It is used to perform operations on Word Application / Word documents.
Class value for creating Word Application object – (“Word.Application”)
12. Database operations
a. Database Connection Object
It is used to connect to Databases
Note: Connection string only varies from One Database to another.
Class value for creating database connection object – (“Adodb.Connection”)
———-
b. Database Recordset Object
It is used to perform operations on Database Records.
Class value for creating Database Recordset object – (“Adodb.Recordset”)
13. Dictionary Object
It is used to define key, value pairs.
Class value – (“Scripting.Dictionary”)
14. Regular Expressions
Regular Expression – It is a formula for matching patterns
Constant matching –
india.doc – india.doc
Pattern matching
i*.
ia…..
ib……….
.
.
india.doc
15. Error Handling
Handling expected and unexpected Errors.
Expected Error:
Whenever we use invalid input then we can expect the Error.
Note: We use Invalid Input for Negative Testing
—————-
Unexpected Error:
Scenarios:
i) Availability of the Resource
ii) Resource Response
iii) Insufficient Resource.
VBScript features for Error Handling:
a) Conditional statements
b) Using some built-in Functions
c) Using Exit Statement
d) Using Option explicit statement
e) Using On Error Resume Next
Etc…