"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

June 14, 2011

Learning VBScript

For all good reasons :) I'm learning VBScript

From Wikipedia link.
  • VBSB (Visual Basic Scripting Edition)
  • Can be used to write and embed function in web pages
  • Besides javascript, vbscript that can be used to code client-side scripting in a web browser
  • QTP tool uses VBScript
1. Download vbsedit from link. Evaluation version does not expire

2. Get Started with Hello World Example

MsgBox"Hello World"

3. Next is Example using variables and conversions

Dim varTest
'Variable Naming Convention - starts with var
varTest = "12"
'Convert Variable to Integer
varTest = CInt(varTest)
4. Next is Prime Number calculation example using functions

'Option Explicit - explicitly declare all variables 
Dim varTest
varTest = InputBox("Please Enter Number")
'Function to check for Prime Number
Function CheckPrime(varTest)
Dim i
Dim flag, reminder
flag = 0
i = 2
'Do While Condition Example
 flag = 0
 reminder = varTestMod i
If reminder = 0Then
   MsgBox"Not Prime"
   flag = 1
LoopWhile flag=0And i<varTest-1     
If flag=0then
MsgBox"Prime Number"

5. Next Example is Reading from Excel

Link - Read from Excel

More Reads
Eric Lippert MSDN VBScript Notes
Error Handling in VBScript, Part One
Error Handling In VBScript, Part Two
Error Handling in VBScript, Part Three
VBScript User's Guide

Developing Automation Framework using QTP
Create Test Automation Framework - Introduction
Create Test Automation Framework – Part 1a
Create Test Automation Framework – Part 1b
Create Test Automation Framework – Part 1c

Happy Reading!!

No comments: