VBScript String Functions
1.LCase
2.UCase
3.Left
4.Right
5.Len
6.Mid
LCase Function:Converts a specified string to lowercase.
Syntax:LCase(string)
Ex1:a=LCase("LAKSHMI")
Msgbox a
Output=lakshmi
UCase Function:Converts a specified string to uppercase.
Syntax:UCase(string)
Ex:a=UCase("laxmi")
Msgbox a
Output=LAXMI
Left Function:Returns a specified number of characters from the left side of a string.
Syntax:Left(string,length)
Ex:a=Left("Lakshmi",3)
Msgbox a
Output=Lak
Right Function:Returns a specified number of characters from the right side of a string.
Syntax:Right(string,length)
Ex:a=Right("Lakshmi",3)
Msgbox a
Output=hmi
Len Function:Returns the number of characters in a string.
Syntax:Len(string)
Ex:a=Len("Lakshmi")
Msgbox a
Output=7
Mid Function:Returns a specified number of characters from a string.
Syntax:Mid(string, start[, length])where length is optional.
Ex1:a=Mid("Lakshmi",1)
Msgbox a
Output=Lakshmi
Here starting position of string is 1 and as their is no number specified for length(optional)output is whole string i.e Lakshmi.
Ex2:a=Mid("Lakshmi",4)
Msgbox a
Output=shmi
Starting position is 4 and no length specified result(output)string starts from 4th position of given string to till end of the string i.e shmi
Ex3:a=Mid("Lakshmi",4,3)
Msgbox a
Output=shm
Starting position is 4 and length is 3 result(output)string starts from 4th position of given string and it takes next 2 characters in the string(including 4th position character total becomes 3 characters)and returns the result as shm.
VBScript String Functions(2)
VBScript String Functions(1)
QTP Script to get Version Number,Folder path of QTP installed in System
Script to get folder path where the QTP is installed in your system.
msgbox environment.Value("ProductDir")
D:\Program Files\Mercury Interactive\QuickTest Professional
Script to get name of product(QTP)in your system.
msgbox environment.Value("ProductName")
QuickTest Professional
Script to get qtp version(No.)installed in your system.
msgbox environment.Value("ProductVer")
8.2
QTP Script to Find Name of Operating System and Its Version
QTP Script to find name of your Operating System.
msgbox environment.Value("OS")
QTP Script to find Version of your Operating System.
msgbox environment.Value("OSVersion")
QTP Script to Find Local Host Name of your System
QTP Script To Delete File From Particular Location
QTP Script to delete particular file from particular location.
Set f = CreateObject("Scripting.FileSystemObject")
f.DeleteFile("D:\file1.txt")
The Above Script will remove(delete)notepad naming file1(text file)from D drive.
QTP Script To Create File
Data Driven Testing Using Notepad