Tuesday, 6 July 2021

VB Script Sample programs

'**************************************************** 
'1 To check Vowel,Symbols, Spaces and special character in given string

Option Explicit
Dim str1,char,cnt,vcnt,ccnt,splcnt,spacecnt,i
vcnt=0
ccnt=0
splcnt=0
spacecnt=0
str1=LCase(InputBox("Enter Any Text:   ","String to check "))
Msgbox str1
cnt=Len(str1)
For i=1 to cnt
char=Mid(str1,i,1)
If (char="a" or  char="e" or char="i" or char="o" or char="u" )Then
vcnt=vcnt+1
ElseIf(char="@" or char="#" or char="$" or char="&" or char="*" or char=":" or char="," or char="|" )Then
splcnt=splcnt+1
 Elseif(char=" ") Then
    spacecnt=spacecnt+1
 Else
  ccnt=ccnt+1
End If
Next
Msgbox "Vowel Count:     "&vcnt
Msgbox "Consonent Count:     "&ccnt
Msgbox "Special charactor:     "&splcnt

'****************************************************
'2    Find whether given number is a odd number
Dim oNumber

oNumber=4
If oNumber mod 2 <>0 Then
    MsgBox "The Number "& oNumber &" is an Odd Number"
else
    MsgBox "The Number "& oNumber &" is not an Odd Number"
End If
'****************************************************
'3    MsgBox odd numbers between given range of numbers

Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=10
RangeEnd=20

For iCounter=RangeStart to RangeEnd

    If iCounter mod 2 <>0 Then
        MsgBox  oNumber
    End If

Next

'****************************************************
'4    Find the factorial of a given number
Dim oNumber
Dim iCounter
Dim fValue

oNumber=6
fValue=1

For iCounter=oNumber to 1 step-1
    fValue=fValue*iCounter
Next
MsgBox  fValue

'****************************************************
'5    Find the factors of a given number
Dim oNumber
Dim iCounter

oNumber=10

For iCounter=1 to oNumber/2
    If oNumber mod iCounter=0 Then
        MsgBox iCounter
    End If
Next
MsgBox oNumber
'****************************************************
'6    MsgBox prime numbers between given range of numbers

Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=1
RangeEnd=30

For iCounter=RangeStart to RangeEnd

    For iCount=2 to round(iCounter/2)
            If iCounter mod iCount=0 Then
                Exit for
            End If
    Next
   
    If iCount=round(iCounter/2)+1 or iCounter=1 Then
            MsgBox iCounter
    End If
Next

'****************************************************
'7    Swap 2 numbers with out a temporary variable

Dim oNum1
Dim oNum2

oNum1=1055
oNum2=155

oNum1=oNum1-oNum2
oNum2=oNum1+oNum2
oNum1=oNum2-oNum1
MsgBox oNum1
MsgBox oNum2
'****************************************************
'8    Write a program to Perform specified Arithmetic Operation on two given numbers
Dim oNum1
Dim oNum2
Dim oValue

oNum1=10
oNum2=20

OperationtoPerform="div"

Select Case lcase(OperationtoPerform)

                Case "add"
                                oValue=oNum1+oNum2
                Case "sub"
                                oValue=oNum1-oNum2
                Case "mul"
                                oValue=oNum1*oNum2
                Case "div"
                                oValue=oNum1/ oNum2
End Select
MsgBox oValue
'****************************************************
'9    Find the length of a given string
Dim oStr
Dim oLength
oStr="suresh"
oLength=len(oStr)
MsgBox oLength
'****************************************************
'10    Reverse given string
Dim oStr
Dim oLength
Dim oChar
Dim iCounter

oStr="suresh"
oLength=len(oStr)

For iCounter=oLength to 1 step-1
        oChar=oChar&mid(oStr,iCounter,1)
Next
MsgBox oChar
'****************************************************
'11    Find how many alpha characters present in a string.
Dim oStr
Dim oLength
Dim oChar
Dim iCounter

oStr="su1h2kar"
oLength=len(oStr)

oAlphacounter=0

For iCounter=1 to oLength

    If not isnumeric (mid(oStr,iCounter,1)) then
        oAlphacounter=oAlphacounter+1
    End if
   
Next
MsgBox oAlphacounter

'****************************************************
'12    Find occurrences of a specific character in a string

Dim oStr
Dim oArray
Dim ochr
oStr="suresh"
ochr="a"

oArray=split(oStr,ochr)
MsgBox ubound(oArray)
'****************************************************
'13    Replace space with tab in between the words of a string.

Dim oStr
Dim fStr

oStr="Quick Test Professional"

fStr=replace(oStr," ",vbtab)
MsgBox fStr

'****************************************************
'14    Write a program to return ASCII value of a given character

Dim ochr
Dim aVal

ochr="A"

aVal=asc(ochr)
MsgBox aVal

'****************************************************
'15    Write a program to return character corresponding to the given ASCII value

Dim ochr
Dim aVal

aVal=65

oChr=chr(aVal)
MsgBox oChr

'****************************************************
'16    Convert string to Upper Case
Dim oStr
Dim uStr

oStr="QuickTest Professional"

uStr=ucase(oStr)
MsgBox uStr
'****************************************************
'17    Convert string to lower case
Dim oStr
Dim lStr

oStr="QuickTest Professional"
lStr=lcase(oStr)
MsgBox lStr

'****************************************************
'18    Write a program to Replace a word in a string with another word

Dim oStr
Dim oWord1
Dim oWord2
Dim fStr

oStr="Mercury Quick Test Professional"
oWord1="Mercury"
oWord2="HP"

fStr=replace(oStr,oWord1,oWord2)
MsgBox fStr

'****************************************************
'19    Check whether the string is a POLYNDROM

Dim oStr

oStr="bob"
fStr=StrReverse(oStr)
If oStr=fStr Then
    MsgBox "The Given String "&oStr&" is a Palindrome"
    else
    MsgBox "The Given String "&oStr&" is not a Palindrome"
End If
'****************************************************
'20    Verify whether given two strings are equal
Dim oStr1
Dim ostr2

oStr1="qtp"
oStr2="qtp"
If  oStr1=oStr2 Then
        MsgBox "The Given Strings are Equal"
        else
        MsgBox "The Given Strings are not Equal"
End If
'****************************************************
'21    MsgBox all values from an Array
Dim oArray
Dim oCounter
oArray=array(1,2,3,4,"qtp","Testing")

For oCounter=lbound(oArray) to ubound(oArray)
    MsgBox oArray(oCounter)
Next

'****************************************************
'22    Sort Array elements
Dim oArray
Dim oCounter1
Dim oCounter2
Dim tmp

oArray=array(8,3,4,2,7,1,6,9,5,0)

For oCounter1=lbound(oArray) to ubound(oArray)

        For oCounter2=lbound(oArray) to ubound(oArray)-1

                    If oArray(oCounter2)>oArray(oCounter2+1) Then
                        tmp=oArray(oCounter2)
                        oArray(oCounter2)=oArray(oCounter2+1)
                        oArray(oCounter2+1)=tmp
                    End If
                     
        Next
   
Next

For oCounter1=lbound(oArray) to ubound(oArray)
    MsgBox oArray(oCounter1)
Next
   
'****************************************************
'23    Add two 2X2 matrices
Dim oArray1(1,1)
Dim oArray2(1,1)
Dim tArray(1,1)

oArray1(0,0)=8
oArray1(0,1)=9
oArray1(1,0)=5
oArray1(1,1)=-1

oArray2(0,0)=-2
oArray2(0,1)=3
oArray2(1,0)=4
oArray2(1,1)=0

tArray(0,0)=oArray1(0,0)+ oArray2(0,0)
tArray(0,1)=oArray1(0,1)+oArray2(0,1)
tArray(1,0)=oArray1(1,0)+oArray2(1,0)
tArray(1,1)=oArray1(1,1)+oArray2(1,1)
'****************************************************


'24    Multiply Two Matrices of size 2X2

Dim oArray1(1,1)
Dim oArray2(1,1)
Dim tArray(1,1)

oArray1(0,0)=8
oArray1(0,1)=9
oArray1(1,0)=5
oArray1(1,1)=-1

oArray2(0,0)=-2
oArray2(0,1)=3
oArray2(1,0)=4
oArray2(1,1)=0

tArray(0,0)=oArray1(0,0)* oArray2(0,0)+ oArray1(0,1)* oArray2(1,0)
tArray(0,1)=oArray1(0,0)* oArray2(0,1)+ oArray1(0,1)* oArray2(1,1)
tArray(1,0)=oArray1(1,0)* oArray2(0,0)+ oArray1(1,1)* oArray2(1,0)
tArray(1,1)=oArray1(1,0)* oArray2(0,1)+ oArray1(1,1)* oArray2(1,1)


'****************************************************
'25    Convert a String in to an array

Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr)

For iCounter=0 to ubound(StrArray)
        MsgBox StrArray(iCounter)
Next

'****************************************************
'26    Convert a String in to an array using ‘i‘ as delimiter

Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr,"i")

For iCounter=0 to ubound(StrArray)
        MsgBox StrArray(iCounter)
Next

'****************************************************
'27    Find number of words in string

Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")
MsgBox "Theere are "&ubound(StrArray)+1&" words in the string"

'****************************************************
'28    Write a program to reverse the words of a given string.

Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")

For iCounter=0 to ubound(StrArray)
        MsgBox strreverse(StrArray(iCounter))
Next

'****************************************************
'29    MsgBox the data as a Pascal triangle
'The formulae for pascal triangle is nCr=n!/(n-r)!*r!

Dim PascalTriangleRows
Dim nCr
Dim NumCount
Dim RowCount

PascalTriangleRows = 10
For NumCount = 0 To PascalTriangleRows
    toMsgBox= Space(PascalTriangleRows - NumCount)
    For RowCount = 0 To NumCount
            If (NumCount = RowCount) Then
                    nCr = 1
            Else
                nCr = Factorial(NumCount) / (Factorial(NumCount - RowCount) * Factorial(RowCount))
            End If
     toMsgBox=toMsgBox&nCr&" "
    Next
    MsgBox toMsgBox
Next


Function Factorial(num)
   Dim iCounter
    Factorial = 1
    If num <> 0 Then
        For iCounter = 2 To num
            Factorial = Factorial * iCounter
        Next
    End If
End Function
'****************************************************
'30    Join elements of an array as a string

Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")

MsgBox join(StrArray," ")

'****************************************************
'31    Trim a given string from both sides

Dim oStr

oStr="    QTP    "
MsgBox trim(oStr)

'****************************************************
'32    Write a program to insert 100values and to delete 50 values from an array

Dim oArray()
Dim iCounter

ReDim oArray(100)

For iCounter=0 to ubound(oArray)
            oArray(iCounter)=iCounter
            'MsgBox total 100 Values
            MsgBox(oArray(iCounter))
Next
MsgBox "******************************"
MsgBox "******************************"
ReDim preserve oArray(50)

For iCounter=0 to ubound(oArray)
    'MsgBox Values after deleting 50 values
            MsgBox(oArray(iCounter))
Next
'****************************************************
'33    Write a program to force the declaration of variables

Option explicit    ' this keyword will enforce us to declare variables

Dim x
x=10
'Here we get an error because i have not declared y,z
y=20
z=x+y
MsgBox z
'****************************************************
'34    Write a program to raise an error and MsgBox the error number.

On Error Resume Next
Err.Raise 6   ' Raise an overflow error.
MsgBox  ("Error * " & CStr(Err.Number) & " " & Err.Description)

'****************************************************
'35    Finding whether a variable is an Array

Dim oArray()

if  isarray(oArray) then
    MsgBox "the given variable is an array"
 else
    MsgBox "the given variable is not an array"
End if
'****************************************************
'36    Write a program to list the Timezone offset from GMT
Dim objWMIService
Dim colTimeZone
Dim objTimeZone

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colTimeZone = objWMIService.ExecQuery("Select * from Win32_TimeZone")

For Each objTimeZone in colTimeZone
    MsgBox "Offset: "& objTimeZone.Bias
Next
'****************************************************
'37 Retrieving Time Zone Information for a Computer
Dim objWMIService
Dim colTimeZone
Dim objTimeZone

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colTimeZone = objWMIService.ExecQuery("Select * from Win32_TimeZone")

For Each objItem in colTimeZone

    MsgBox "Bias: " & objItem.Bias
    MsgBox "Caption: " & objItem.Caption
    MsgBox "Daylight Bias: " & objItem.DaylightBias
    MsgBox "Daylight Day: " & objItem.DaylightDay
    MsgBox "Daylight Day Of Week: " & objItem.DaylightDayOfWeek
    MsgBox "Daylight Hour: " & objItem.DaylightHour
    MsgBox "Daylight Millisecond: " & objItem.DaylightMillisecond
    MsgBox "Daylight Minute: " & objItem.DaylightMinute
    MsgBox "Daylight Month: " & objItem.DaylightMonth
    MsgBox "Daylight Name: " & objItem.DaylightName
    MsgBox "Daylight Second: " & objItem.DaylightSecond
    MsgBox "Daylight Year: " & objItem.DaylightYear
    MsgBox "Description: " & objItem.Description
    MsgBox "Setting ID: " & objItem.SettingID
    MsgBox "Standard Bias: " & objItem.StandardBias
    MsgBox "Standard Day: " & objItem.StandardDay
    MsgBox "Standard Day Of Week: " & objItem.StandardDayOfWeek
    MsgBox "Standard Hour: " & objItem.StandardHour
    MsgBox "Standard Millisecond: " & objItem.StandardMillisecond
    MsgBox "Standard Minute: " & objItem.StandardMinute
    MsgBox "Standard Month: " & objItem.StandardMonth
    MsgBox "Standard Name: " & objItem.StandardName
    MsgBox "Standard Second: " & objItem.StandardSecond
    MsgBox "Standard Year: " & objItem.StandardYear
   
Next

'****************************************************
'38    Write a program to Convert an expression to a date
Dim StrDate
Dim actualDate
Dim StrTime
Dim actualTime

StrDate = "October 19, 1962"   ' Define date.
actualDate = CDate(StrDate)   ' Convert to Date data type.
MsgBox actualDate
StrTime = "4:35:47 PM"         ' Define time.
actualTime = CDate(StrTime)   ' Convert to Date data type.
MsgBox actualTime

'****************************************************
'39 Display current date and Time

MsgBox now
'****************************************************
'40    Find difference between two dates.

'Date difference in Years
MsgBox DateDiff("yyyy","12/31/2002",Date)

'Date difference in Months
MsgBox DateDiff("m","12/31/2002",Date)

'Date difference in Days
MsgBox DateDiff("d","12/31/2002",Date)

'****************************************************
'41    Add time interval to a date

MsgBox DateAdd("m", 1, "31-Jan-95")

'****************************************************
'42    MsgBox current day of the week

MsgBox day(date)
'****************************************************
'43    Find whether current month is a long month
Dim oCurrentMonth
Dim ocurrentYear
Dim oDaysinMonths

oCurrentMonth = Month(date)
ocurrentYear = Year(date)
oDaysinMonths=Day(DateSerial(ocurrentYear, oCurrentMonth + 1, 0))
MsgBox oDaysinMonths&" Days in Current Month"
If oDaysinMonths=31 Then
    MsgBox "Current Month is a long month"
else
    MsgBox "Current Month is not a long month"
End If
'****************************************************
'44    Find whether given year is a leap year

'1st Method

'The rules for leap year:
'1. Leap Year is divisible by 4    (This is mandotory Rule)
'2. Leap Year is not divisible by 100 (Optional)
'3. Leap Year divisble by 400 (Optional)

Dim oYear

oYear=1996

If ((oYear Mod 4 = 0) And (oYear Mod 100 <> 0) Or (oYear Mod 400 = 0)) then
    MsgBox "Year "&oYear&" is a Leap Year"
else
    MsgBox "Year "&oYear&" is not a Leap Year"
End If


'45.    2nd Method
' Checking 29 days for February month in specified year
Dim oYear
Dim tmpDate

oYear=1996
tmpDate = "1/31/" & oYear
DaysinFebMonth = DateAdd("m", 1, tmpDate)

If  day(DaysinFebMonth )=29 then
    MsgBox "Year "&oYear&" is a Leap Year"
else
    MsgBox "Year "&oYear&" is not a Leap Year"
End If

'****************************************************
'46    Format Number to specified decimal places

Dim oNum
Dim DecimaPlacestobeFormat
oNum = 3.14159
DecimaPlacestobeFormat=2
MsgBox Round(oNum , DecimaPlacestobeFormat)

'****************************************************
'47    Write a program to Generate a Random Numbers
'This script will generate random numbers between 10 and 20
Dim rStartRange
Dim rEndRange

rStartRange=10
rEndRange=20

For iCounter=1 to 10
    MsgBox Int((rEndRange - rStartRange + 1) * Rnd + rStartRange)
Next
'****************************************************
'48    Write a program to show difference between Fix and Int

'Both Int and Fix remove the fractional part of number and return the resulting integer value.
'The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number,
'whereas Fix returns the first negative integer greater than or equal to number.
'For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

MsgBox Int(99.8)    ' Returns 99.
MsgBox Fix(99.2)    ' Returns 99.
MsgBox Int(-99.8)   ' Returns -100.
MsgBox Fix(-99.8)   ' Returns -99.
MsgBox Int(-99.2)   ' Returns -100.
MsgBox Fix(-99.2)   ' Returns -99.

'****************************************************
'49    Write a program to  find subtype of a variable

Dim oVar
Dim oDatatypes
oVar="QTP"
oVartype=Typename(oVar)
MsgBox oVartype

'****************************************************
'50    Write a program to MsgBox the decimal part of a given number
Dim oNum
oNum=3.123
oDecNum=oNum- int(oNum)
MsgBox oDecNum
'****************************************************

How to split a string or number with four digits using vb script

strString = "12345678909876543210"
For i=1 To Len(strString) step 4
    WScript.Echo Mid(strString,i,4)
Next

--------------------
-Out put is:

1234
5678
9098
7654
3210

How do you get number of lines in text file using file system object in uft/qtp

--Save as same file with .txt with below code or use any other txt file and change the path of the file.

Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile("D:\VB Programs\Test.txt", 8, True)
WScript.Echo "Number of lines : " &theFile.Line
Set oFso = Nothing

-Output:
Number of lines: 4

UFT Interview questions

QTP/UFT Questions:
1. What is Object Repository, and Types?
2. What is Descriptive Programming?
3. Different Types of Frameworks and Approach?
4. How can we identify whether the test case can be automated or not / Factors to be considered for automation of any test cases?
5. What is the difference between function and procedure?
6. Difference between Action and Function?
7. Different types of actions?
8. How can you handle dynamically changing object properties?
9. What is the difference between absolute and relative path?
10. Types of Recovery Scenarios?
11. How do your convert Local Repository to Shared repository?
12. How do you invoke application using utility object (Invoke application and SystemUtil.Run)? What is the difference between them?
13. Types of Loops and Conditional statements in VB Scripting?
14. What is option explicit?
15. Difference between conditional statements(If else and Switch case), which one is preferred?
16. Types of Environment variables and differences between them?
17. Difference between Local repository and Shared Repository?
18. If two objects in AUT are having the same object properties, how QTP identify the objects?
19. In an general scenario if a screen having five objects, what is your approach to automate that screen(what type of framework you are going to implement)?
20. Difference between For and For each?
21. Can u pass values from action to functions by using arguments and vice versa?
22. List some of the critical challenges you encountered in your current framework. Explain the resolution for the challenges?
23. In a web table, there are object classes like Radio Buttons, Checkboxes, and Buttons etc. How do you get the count of Radio Buttons exists in that web table?
24. Please explain one best user defined recovery scenario & exception handling cases in your current framework?
25. There are 2 library files and a function with name “Login” is available in both the library files. When we call the function from an action, from which library file the function will be executed?
26. How do you get the properties of an object in run time without using ‘GetORProperty’
27. There is an Object on application and its properties are dynamically changing. None of the properties are constant. In this situation, what is your approach to identify the object?
28. There is a string VAM391#@. How do you get number of characters, numeric & special characters exists in the string?
29. What is the significance of EVAL method in VB Scripting?
30. List some of the precautions you will take for successful batch execution?
31. How do you overcome Sync issues without using hard coded wait statements?

Database Questions:
1. Types of joins and differences between them?
2. What is the difference between Primary Key and Unique Key?
3. Difference between Foreign and Primary key?
4. Explain about Sub Queries and Union All command?
5. What is Normalization? Different types of Normalizations?
6. What is Referential Integrity?
7. How to establish connection to Database?
8. Explain about Select Queries with Where Clause, Having, GroupBy and Order by

In a recent interview:
1. What is a framework?
2. Why do we use Arrays?
3. How to capture the length of a string?
4. How do we capture properties of an object at Run time?
5. Explain about a Defect that you found using scripts?
6. How do you handle object properties that change?
7. Explain difference between if and Case statement

Difference between Invokeapplication and systemutil.run in QTP

 
In Systemutil.run you can provide name(or .exe) of the file directly, But in case of invokeapplication you have to pass full path of the .exe in your computer.
Example:  Systemutil.run "iexplore.exe" will work but
InvokeApplication "iexplore.exe" will not work instead of this you have to provide
InvokeApplication "C:\Program Files (x86)\Internet Explorer\iexplore.exe"

Difference between Executefile and loadfunctionlibrary in QTP

With executefile, we can’t debug the statements. 
With loadfunctionlibrary, we can load multiple library files separated by comma and we can debug as well. If you want to debug, you can associate files with action.

---
In execute file ,we will execute .vbs,.qfl,.txt files but in loadfunctionlibrary only we associate .qfl files why because this mechanism introduced in qtp 11.0 version
executefile "path.qfl"
executefile "path.vbs"
in load fucnction library we jst associate the qfl files

Interview questions from other Blogger

How to find repeated words in given string

Dim MyString, str, i, a, j, temp

MyString = "This is to check how many words to check"
str = Split(MyString, " ", -1, 1)
For i = 0 to UBound(str)-1
  For j=i+1 to UBound(str)
     if str(i)=str(j) then
str2=str(i)
'str3=str2 &"," &str2
MsgBox "Repeated word in given string : " &str2
     end if
Next
Next

--Out put:
Repeated word in given string : check
Repeated word in given string : to


How to get string, number and special charters in given string

strstring= "Suresh12#234232%@!%%"

For i =1 to Len(strstring)
str=mid(strstring,i,1)
if IsNumeric(str) then
numeric=numeric+str

ElseIf ASC(str)>64 and ASC(str)<123 then
string1=string1+str

Else
specialChar=specialChar+str
End If
Next

msgbox "Numaric charcters are in given string : "&numeric
msgbox "String is : "&string1
msgbox "Special Charcheters are in given string : "&specialChar


Sample QTP scripts

'Code for printing the files in a folder
Option Explicit
Dim fso,fld,sFiles,sFile
Set fso=CreateObject("Scripting.FileSystemObject")
Set fld=fso.GetFolder("C:\Documents and Settings\Administrator\Desktop\Project")
Set sFiles=fld.Files
For each sFile in sFiles
  print sFile.Name
Next
Set fso=nothing


‘++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'Code for Action Parameters by using Input,Output Parameters
a=10
b=20
Datatable.LocalSheet.AddParameter "Sum",""
Datatable.LocalSheet.AddParameter "Diff",""
Datatable.LocalSheet.AddParameter "Prod",""
RunAction "Action2", oneIteration,a,b,sum1,diff1,prod1
'RunAction "Action2", oneIteration,a,b,Datatable(1,2),Datatable(2,2),Datatable(3,2)
wait 3
Msgbox "Sum:   "&sum1
Msgbox "Diff:   "&diff1
Msgbox "Prod:   "&prod1


'Code for creating input,output parameters
Option Explicit
Dim n1,n2,sum,diff,prod
n1=Parameter("Num1")
n2=Parameter("Num2")
sum=n1+n2
diff=n2-n1
prod=n1*n2
Parameter("s")=sum
Parameter("d")=diff
Parameter("p")=prod


Code for actions
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "jampani007" @@ hightlight id_;_1049510_;_script infofile_;_ZIP::ssf1.xml_;_
Dialog("Login").WinEdit("Agent Name:").Type  micTab @@ hightlight id_;_1049510_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").SetSecure "4a3f0a7be1e01cd14cdbff178464bf5992d35800" @@ hightlight id_;_393928_;_script infofile_;_ZIP::ssf3.xml_;_
Dialog("Login").WinEdit("Password:").Type  micReturn @@ hightlight id_;_393928_;_script infofile_;_ZIP::ssf4.xml_;_


RunAction "Copy of Create_order", oneIteration
RunAction "Fax_order", oneIteration
RunAction "Copy of Logout", oneIteration


'Code for finding the Broken links by using child objects
Option Explicit
Dim brlnk,desc,cnt,i,coll,oShell,link
SystemUtil.Run "www.yatra.com"
Set oShell=CreateObject("wscript.shell")
Set desc=Description.Create
desc("html tag").Value="A"
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
cnt=coll.count
oShell.popup "No of Links:   "&cnt,2,"Links Info"
For i=0 to cnt-1
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
'link=coll(i).GetRoProperty("name")
oShell.popup coll(i).GetRopRoperty("name"),1,"Link Info"
coll(i).click
If (coll(i).GetRoProperty("title")="The page cannot be disp") Then
brlnk=brlnk+1
End If
Browser("Yatra.com My Bookings").Back
Next
Msgbox "No of Broken Links:   "&brlnk
Set oShell=nothing
'Code for Built-In Enviroment Variables to read system info
Msgbox "Computer Name:    "&Environment.Value("LocalHostName")
Msgbox "Operating System:    "&Environment.Value("OS")
Msgbox "OS Version:    "&Environment.Value("OSVersion")
Msgbox "Action Name:    "&Environment.Value("ActionName")
Msgbox "Action Iteration:    "&Environment.Value("ActionIteration")
Msgbox "TestName:    "&Environment.Value("TestName")
Msgbox "Test Iteration:    "&Environment.Value("TestIteration")
Msgbox "ProductName:    "&Environment.Value("ProductName")
Msgbox "Product Version:    "&Environment.Value("ProductVer")
Msgbox "Product Dir:    "&Environment.Value("ProductDir")
Msgbox "Test Dir:    "&Environment.Value("TestDir")
'Code for capturing the text forom a webpage by using GetCellData()
Option Explicit
Dim rowcnt,colcnt,rowno,colno,celldata,oShell
Set oShell=CreateObject("wscript.shell")
rowcnt=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("index:=2").RowCount
'Msgbox "Row count:    "&rowcnt
oShell.popup "Row count:    "&rowcnt,2,"Row Info"
For rowno=1 to rowcnt
 colcnt=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("Index:=2").ColumnCount(rowno)
' Msgbox "Column Count:  "&colcnt
oShell.popup "Column count:    "&colcnt,2,"Col Info"
             For colno=1 to colcnt
                 celldata=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("Index:=2").GetCellData(rowno,colno)
 If (celldata<>"") Then
 oShell.popup  celldata,1,"Cell Info"
 End If
   Next
Next


'Code for capturing the text from a window by using GetVisibleText()
Option Explicit
Dim str1,str2,pos,res
str1=window("Flight Reservation").Dialog("About Flight Reservation").GetVisibleText()
Msgbox str1
str2="Version 4.0"
pos=Instr (1,str1,str2,VBTextCompare)
Msgbox pos
If (pos<>0) Then
res=Mid(str1,pos,11)
   If (res=str2) Then
Msgbox "The string exist:     "&res
Else
Msgbox "The string does not exist:   "&pos
End If
End If
'Code for capturing the text from a webpage by using GetCellData()
Option Explicit
Dim web,rowcnt,colcnt,rowno,colno,celldata,cnt,coll,oShell,i
Set oShell=CreateObject("wscript.shell")
Set web=Description.Create
'web("micclass").value="WebTable"
web.add "html tag","TABLE"
Set coll=Browser("India Hotels| Star Hotels|").Page("India Hotels| Star Hotels|").ChildObjects(web)
cnt=coll.count
oShell.popup "Web Tables Count:    "&cnt,2,"Web Table Info"
For i=0 to cnt
rowcnt=coll(i).Rowcount
'oShell.popup "Row Count:     "&rowcnt,2,"Row Info"
  For rowno=1 to rowcnt
       colcnt=coll(i).columncount(rowno)
   ' oShell.popup "Column Count:     "&colcnt,2,"Col Info"
    For colno=1 to colcnt
celldata=coll(i).GetCellData(rowno,colno)
               If (celldata<>"") Then
'oShell.popup celldata,1,"Cell Info"
print celldata
End If
Next
  Next
Next
'Code for checking the DNS services by using oShell Object
Option Explicit
Dim fso,myfile,str,pos,oShell,res
Const ForReading=1
Set oShell=CreateObject("wscript.shell")
oShell.run "CMD /c net start > D:\myfile123.txt"
Set fso=CreateObject("Scripting.FilesystemObject")
Set myfile=fso.OpenTextfile("D:\myfile123.txt",ForReading,False)
While myfile.AtEndOfStream<>True
str=myfile.Readall
   pos=Instr (1,str,"DNS Client",VBTextCompare)
If (pos<>0) Then
 res=Mid(str,pos,10)
 msgbox res
 If (res="DNS Client") Then
 Msgbox "DNS Services Running   "&res
 Else
 Msgbox "DNS Services not Running"
 End If
End If
Wend
set oShell=nothing


browser("Google Accounts").Page("Google Accounts").Image("Visual verification").CaptureBitmap "D:\img.bmp" @@ hightlight id_;_3146758_;_script infofile_;_ZIP::ssf1.xml_;_
'Code for finding the Hyper Links in a webpage by using Child Objects
Option Explicit
Dim oLink,coll,cnt,i,link,oShell
Datatable.GlobalSheet.AddParameter "MyLinks",""
set oShell=CreateObject("wscript.shell")
Set oLink=Description.Create
'oLink("micclass").value="Link"
oLink("html tag").value="A"
Set coll=Browser("CreationTime:=0").Page("index:=0").ChildObjects(oLink)
cnt=coll.Count
'Msgbox "No of Hyper Links:    "&cnt
oShell.popup "No of Hyper Links:    "&cnt,2,"Links Info"
For i=0 to cnt-1
'Datatable.SetCurrentRow(i+1)
link=coll(i).GetROProperty("name")
If (link<>"") Then
oShell.popup link,1,"Links Info"
End If


If (link="blogs") Then
coll(i).click
Exit For
End If
Exit For
Datatable.Value("MyLinks","Global")=link
Print coll(i).GetROProperty("name")
Next


datatable.ExportSheet "D:\shruthi.xls","Global"
Set oLink=Nothing
'Code for closing the multiple Browsers
Option Explicit
Msgbox Browser("CreationTime:=0").Exist
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").page("Index:=0").webedit("index:=0").Set "raghuqa"
wait 1
Browser("CreationTime:=0").page("Index:=0").webedit("index:=1").SetSecure "4a2b3fd87cbee9b873cbb15580f68489d5e426f73945c9806993"
wait 1
Browser("CreationTime:=0").page("Index:=0").webbutton("index:=0").Click
wait 1
Browser("CreationTime:=0").page("Index:=1").Link("index:=0").Click
wait 1
Browser("CreationTime:=0").Close
Wend
' code for closing multiple windows
Option explicit
Msgbox Dialog("index:=0","text:=Login").Exist
While  Dialog("index:=0","text:=Login").Exist
Dialog("index:=0","text:=Login").WinEdit("index:=0","attached text:=Agent Name:").Set "asdf"
wait 1
Dialog("index:=0","text:=Login").WinEdit("index:=1","attached text:=Password:").Set "mercury"
wait 1
Dialog("index:=0","text:=Login").WinButton("index:=0","text:=OK").Click
wait 1
window("text:=Flight Reservation").Close
Wend
'Code for creating the text file by using the FSO
Option Explicit
Dim fso,myFolder,myfile
Const Forwriting=2,ForAppending=8
Set fso=CreateObject("scripting.filesystemobject")
Set myFolder=fso.CreateFolder("D:\shruthi")
Set myfile=fso.Createtextfile("D:\shruthi\file123.txt",Forwriting,True)
'Set myfile=fso.OpenTextFile("D:\shruthi\file123.txt",ForAppending ,True)
myfile.writeline "My Name is Krish"
myfile.writeblanklines(1)
myfile.writeline "My Name is Raghu"
myfile.writeblanklines(1)
myfile.writeline "My Name is Srinivas"
myfile.close
Set fso=Nothing
Set myfile=Nothing
Set myFolder=Nothing


'Code for DataBase Connection first method with DSN
Option Explicit
Dim conn,recobj,recordcnt,fieldscnt,col,i,j
Datatable.AddSheet("Jampani")
Set conn=CreateObject("ADODB.Connection")
conn.open "DSN=QT_Flight32"
'conn.open "Server=jampani;Driver=Microsoft Access Driver (*.mdb);DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Trusted_Connection=yes"
'conn.open "Server=jampani;Driver=SQL Server;DataBase=Master;UserID=sa;Password=sa"
'conn.open "Server=jampani;Driver=OracleDriver;DataBase=Master;UserID=sa;Password=sa"


Msgbox "Connection Status:     "&conn.State
If (conn.state=1) Then
Reporter.ReportEvent micPass,"Checking the DataBase Connections","DB Connection success"
Else
Reporter.ReportEvent  micFail,"Checking the DataBase Connections","DB Connection failure"
End If
Set recobj=CreateObject("ADODB.Recordset")
recobj.open "Select * from Flights where Flight_Number<1110",conn,1
recordcnt=recobj.recordcount
msgbox "Record Count:   "&recordcnt
fieldscnt=recobj.fields.count
Msgbox "Fields count:    "&fieldscnt
For each col in recobj.fields
Datatable.GetSheet("Jampani").Addparameter col.Name,""
Next
For i=0  to recordcnt-1
Datatable.SetCurrentRow(i+1)
    For j=0 to fieldscnt-1
          Datatable.Value(j+1,"Jampani")=recobj(j)
Next
recobj.movenext
Next
'Datatable.ExportSheet "c:\bharathi.xls","Jampani"
recobj.save "D:\bharathi.xml",1
recobj.save "D:\bharathi.txt",1
conn.close
Set conn=nothing
Set recobj=nothing


'Code for designing the HTML doc By using the FSO
Option Explicit
Dim fso,myfile
Const Forwriting=2
Set fso=CreateObject("Scripting.FilesystemObject")
Set myfile=fso.CreateTextFile("D:\file1234.html",ForWriting,True)
myfile.writeline "<html>"
myfile.writeline "<head>"
myfile.writeline "<title>TestCase Results</title>"
myfile.writeline "</head>"
myfile.writeline "<body bgcolor=green>"
myfile.writeline "<center>"
myfile.writeline "<h1>Test Case Results</h1>"
myfile.writeline "<br><br><br><br>"
myfile.writeline "<table bgcolor=red border=2 align=center>"
myfile.writeline "<tr><th>Sno</th><th>TestCase</th><th>Exp.Results</th><th>Act.Results</th><th>StartTime</th><th>Status</th></tr>"
myfile.writeline "<tr><td>1</td><td>Login</td><td>Login should be open</td><td>Login should be success</td><td>"&Now&"</td><td>Pass</td></tr>"
myfile.writeline "<tr><td>2</td><td>Inser Order</td><td>Inser Order should be open</td><td>Inser Order should be success</td><td>"&Now&"</td><td>Pass</td></tr>"
myfile.writeline "<tr><td>3</td><td>Update Order</td><td>Update Order should be open</td><td>Update Order should be success</td><td>"&Now&"</td><td>Fail</td></tr>"
myfile.writeline "</table>"
myfile.writeline "</body>"
myfile.writeline "</center>"
myfile.writeline "</html>"
myfile.close
Set fso=nothing
Set myfile=nothing
'Code for external environment variables
Option Explicit
Dim path1,ph1
path1=Environment.ExternalFileName


Msgbox IsEmpty(path1)
If (path1=Empty) Then
Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\shruthi\Envfile.xml"
Msgbox "UserID:   "&Environment.Value("UserID")
Msgbox "Password:   "&Environment.Value("Password")
Msgbox "Job:   "&Environment.Value("Job")
Msgbox "Sal:   "&Environment.Value("Sal")
Msgbox "Location:   "&Environment.Value("Location")
Else
Msgbox "File Already in use:   "&path1
End If
Code for external actions
RunAction "Login [Code for actions]", oneIteration
'Code for getting the drives info by using FSO
Option Explicit
Dim fso,oDrive,driv,strout
Set fso=CreateObject("scripting.filesystemobject")
Set oDrive=fso.Drives
For each driv in oDrive
strout=strout&"Available Drives:    "&driv.DriveLetter&VBCrlf
strout=strout&"IS Ready:    "&driv.IsReady&VBCrlf
strout=strout&"Drive Type:    "&driv.DriveType&VBCrlf
strout=strout&"VolumeName:    "&driv.VolumeName&VBCrlf
strout=strout&"Drive Path:    "&driv.Path&VBCrlf
strout=strout&"RootFolder:    "&driv.RootFolder&VBCrlf
strout=strout&"SerialNumber:    "&driv.SerialNumber&VBCrlf
strout=strout&"FileSystem:    "&driv.FileSystem&VBCrlf
strout=strout&"Free space:    "&driv.Freespace&VBCrlf
strout=strout&"FileSystem:    "&driv.TotalSize&VBCrlf
Next
Msgbox strout


'Code for launching the Browser
Option Explicit
Dim ie,url
Public Function Launch_Browser(url)
  Set ie=CreateObject("InternetExplorer.Application")
  ie.visible=true
  ie.ToolBar=1
  ie.Navigate url
  Set ie=Nothing
End Function


Call Launch_Browser("www.google.com")
Call Launch_Browser("www.rediffmail.com")
'+++++++++++++++++++++++++++++++++++++++++++++++++
Public Function Launch_App(arg1)
  Set wsh=CreateObject("wscript.shell")
  wsh.run arg1
  Set wsh=nothing
End Function


Call Launch_App("Notepad.exe")
wait 1
Call Launch_App("cmd.exe")
wait 1
Call Launch_App("www.google.com")
wait 1
Call Launch_App("EXCEL.EXE")
wait 1
Call Launch_App("calc.exe")
wait 1
Call Launch_App("www.msn.com")


'+++++++++++++++++++++++++++++++++++++++++++++++++++++
InvokeApplication "notepad.exe"
wait 1
InvokeApplication "cmd.exe"
wait 1
InvokeApplication "EXCEL.EXE"
wait 1
InvokeApplication "WINWORD.EXE"
wait 1
InvokeApplication "calc.exe"
wait 1
InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
Systemutil.Run "Notepad.exe"
wait 1
Systemutil.Run "www.bharathmatrimony.com"
wait 1
Systemutil.Run "C:\Documents and Settings\Administrator\Desktop\Scripts"
wait 1
systemutil.Run "C:\Documents and Settings\Administrator\Desktop\Day-5th.xls"


'Code for reading text from text file by using FSO
Option Explicit
Dim fso,myfile,str
Const Forreading=1
Set fso=CreateObject("scripting.filesystemobject")
Set myfile=fso.OpenTextfile("D:\Anup.txt",ForReading,false)
While myfile.Atendofline<>true
str=myfile.readline
msgbox str
Wend
myfile.close
Set fso=nothing
Set myfile=nothing
'Code for reading the XML file by using XMLUtil.CreateObject
Option Explicit
Dim doc,root,child,childitem,subchild,subitem,cnt,cnt1,i,j
Set doc=XMLUtil.CreateXML
doc.LoadFile "C:\Documents and Settings\Administrator\Desktop\env123.xml"
Msgbox doc
Set root=doc.GetRootElement
'Msgbox "Root Element Name:   "&root.ElementName
'Msgbox "Root Element Value:   "&root.Value
Set child=root.Childelements
cnt=child.count
'msgbox "Child Count:   "&cnt
For i=1 to cnt
Set childitem=child.item(i)
'Msgbox "Child Item Name:   "&childitem.ElementName
'Msgbox "Child Item Value:   "&childitem.Value
Set subchild=childitem.childElements
cnt1=subchild.count
'Msgbox "Subchild Count:    "&cnt1
   For j=1 to cnt1   
  Set subitem=subchild.Item(j)
  Msgbox "Sub child Item:   "&subitem.ElementName
  Msgbox "Sub child Item:   "&subitem.Value
Next
Next
Set doc=Nothing
Set child=nothing
Set childitem=nothing
Set subchild=nothing
Set subitem=nothing
'Code for registry keys -FSO,oShell,Dictionary objects
Option Explicit
Dim  oShell
set oShell=CreateObject("wscript.shell")
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID","scripting.filesystemobject","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID","wscript.shell","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID","scripting.dictionary","REG_SZ"
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID")
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\ie\ProgID","InternetExplorer.Application","REG_SZ"
Set oShell=Nothing


'Code for Built-In Enviroment Variables to read system info
Msgbox "Computer Name:    "&Environment.Value("LocalHostName")
Msgbox "Operating System:    "&Environment.Value("OS")
Msgbox "OS Version:    "&Environment.Value("OSVersion")
Msgbox "Action Name:    "&Environment.Value("ActionName")
Msgbox "Action Iteration:    "&Environment.Value("ActionIteration")
Msgbox "TestName:    "&Environment.Value("TestName")
Msgbox "Test Iteration:    "&Environment.Value("TestIteration")
Msgbox "ProductName:    "&Environment.Value("ProductName")
Msgbox "Product Version:    "&Environment.Value("ProductVer")
Msgbox "Product Dir:    "&Environment.Value("ProductDir")
Msgbox "Test Dir:    "&Environment.Value("TestDir")


***************************************************


'Code for finding the Broken links by using child objects
Option Explicit
Dim brlnk,desc,cnt,i,coll,oShell,link
Set oShell=CreateObject("wscript.shell")
Set desc=Description.Create
desc("html tag").Value="A"
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
cnt=coll.count
oShell.popup "No of Links:   "&cnt,2,"Links Info"
For i=0 to cnt-1
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
'link=coll(i).GetRoProperty("name")
oShell.popup coll(i).GetRopRoperty("name"),1,"Link Info"
coll(i).click
If (coll(i).GetRoProperty("title")="Cannot find server") Then
brlnk=brlnk+1
End If
Browser("Yatra.com My Bookings").Back
Next
Msgbox "No of Broken Links:   "&brlnk
Set oShell=nothing


*****************************************************
'Code for external environment variables
Option Explicit
Dim path1,ph1
path1=Environment.ExternalFileName


Msgbox IsEmpty(path1)
If (path1=Empty) Then
Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\shruthi\Envfile.xml"
Msgbox "UserID:   "&Environment.Value("UserID")
Msgbox "Password:   "&Environment.Value("Password")
Msgbox "Job:   "&Environment.Value("Job")
Msgbox "Sal:   "&Environment.Value("Sal")
Msgbox "Location:   "&Environment.Value("Location")
Else
Msgbox "File Already in use:   "&path1
End If


*******************
'To log off
set a=createobject("wscript.shell")
spth="%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
a.run spth,0,false


****************************************


to Shut down


set a=createobject("wscript.shell")
a.sendkeys "%{F4}"
a.sendkeys "{TAB}"
a.sendkeys "~"


********************************


'Code for registry keys -FSO,oShell,Dictionary objects
Option Explicit
Dim  oShell
set oShell=CreateObject("wscript.shell")
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID","scripting.filesystemobject","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID","wscript.shell","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID","scripting.dictionary","REG_SZ"
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID")
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\ie\ProgID","InternetExplorer.Application","REG_SZ"
Set oShell=Nothing


recovery
Function RecoveryFunction1(Object)
Object.close
Dialog("Login").WinEdit("Agent Name:").set "raghu"
Dialog("Login").WinButton("OK").click
Window("text:=Flight Reservation").close
End Function


'Code for recovery scenarios to handle runtime errors
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "Ram"
wait 1
Dialog("Login").WinEdit("Agent Name:").Type  micTab
Dialog("Login").WinEdit("Password:").SetSecure "4a444d321297d3fcbf6501e84b81d89dd5019247"
wait 1
Dialog("Login").WinEdit("Password:").Type  micTab
Dialog("Login").WinButton("OK").Type  micReturn
window("text:=Flight Reservation").Close
Dialog("Login").WinEdit("Agent Name:").Set "raghu"
wait 1
Dialog("Login").WinButton("OK").Click
window("text:=Flight Reservation").Close


'Code for getting vowel,consonent and special char count
Option Explicit
Dim str1,char,cnt,vcnt,ccnt,splcnt,spacecnt,i
vcnt=0
ccnt=0
splcnt=0
spacecnt=0
str1=LCase(InputBox("Enter Any Text:   "))
Msgbox str1
cnt=Len(str1)
For i=1 to cnt
char=Mid(str1,i,1)
If (char="a" or  char="e" or char="i" or char="o" or char="u" )Then
vcnt=vcnt+1
ElseIf(char="@" or char="#" or char="$" or char="&" or char="*" or char=":" or char="," or char="|" )Then
splcnt=splcnt+1
 Elseif(char=" ") Then
    spacecnt=spacecnt+1
 Else
  ccnt=ccnt+1
End If
Next
Msgbox "Vowel Count:     "&vcnt
Msgbox "Consonent Count:     "&ccnt
Msgbox "Special charactor:     "&splcnt
Msgbox "space Count:     "&spacecnt