QTP scripts examples

In this post, we will write some QTP scripts. Also, you can check my previous posts on:
1- Leap year or not?
Dim Year
Year=inputbox(“Enter year”)
If year mod 4=0 Then
msgbox “Leap year”
msgbox”Not leap year”
End If
2- Even or odd number
Dim number
number=input box(“Enter number”)
If number mod 2=0 Then
msgbox “Even number”
msgbox”odd number”
End If
3- To add 2 number
Dim num1,num2,sum
num1=inputbox(“Enter number”)
num2=inputbox(“Enter number”)
sum=cint(num1)+cint(num2)//Cint is used here for string conversion
msgbox (“Sum is”& Sum)
4- To calculate Simple Intrest
Dim p,t,r,si
p=inputbox(“Enter number”)
t=inputbox(“Enter number”)
r=inputbox(“Enter number”)
msgbox (“Simple intrest  is”& si)
5- Reverse a string
StrtoReverse = inputbox(“Enter the String:”)
StrLenCount = Len(StrtoReverse)
For i = 1 to StrLenCount
StrReversed = Mid(StrtoReverse,i,1) & StrReversed
Msgbox StrReversed
6- Find how many  “G” are available in the word “Google”.
Const ForReading = 1
Set fso = CreateObject( “Scripting.FileSystemObject” )
Set textFile = fso.OpenTextFile( “D:\sample.txt”,1)
contents = textFile.ReadAll
Set rgxp = New Regexp
rgxp.Pattern = “m”
rgxp.IgnoreCase = True’ To ignore upper case and lower case
rgxp.Global = True
Set matches = rgxp.Execute( contents )
Print “Number of G: ” & matches.Count
Check out Best Alternative to InfoPath -> Try Now


New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

(Installation & Features)

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →