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”
else
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”
else
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”)
si=(p*t*r)/100
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
Next
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
textFile.Close
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

You May Also like the Following SharePoint Online Tutorials:

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 →

Leave a Reply