Monday, February 23, 2009

Script for Mutlipication Tables

Hi All,
Here i am providing the way creating Multiplication Table in Notepad using QTP.
SystemUtil.Run "notepad"
Window("text:=Untitled - Notepad").Activate
For I=1 to 3
For J = 1 to 10
x = I * J
Window("text:=Untitled - Notepad").Type I &"*"& J &"=" &x
Window("text:=Untitled - Notepad").Type micReturn
Next
Next

Output :





Sunday, February 22, 2009

Get Column Count,Col names of DataTable

HI All,
Here i am posting the ways of retreiving the column count & column names used in datasheets of datatable.
Implement the given ways accordingly........Have a Nice day.

'**************************************
To Retrieve the Column count Data Table :
'**************************************
Syntax :
Col_count= Datatable.GetSheet("SheetName").GetParameterCount
Example1:
Col_count= Datatable.GetSheet("Action1").GetParameterCount
msgbox "No. of columns used in "&Environment("ActionName")&" are : " &Col_count
'*****************************************
To Retrieve the Column Names of Data Table :
'*****************************************
Syntax :
Datatable.GetSheet("SheetName").GetParameter(Column Number).Name
Example1 :
Col_Name=Datatable.GetSheet("Action1").GetParameter(1).Name
msgbox " Column name is : "&Col_Name

Create List Box in VB script

Hi All,
JUST COPY PASTE BELLOW CODE IN QTP AND EXECUTE ....
Function Create_List_Dialog(Title, message, List)
On Error Resume Next
msg = message
for i = lbound(List) to ubound (List)
newmess = msg & vbCrLf & cstr(i + 1) & " - " & List(i)
msg = newmess
next
flag = 0
do while flag = 0
Ret = InputBox(msg,Title,"1")
Ret = CInt(Ret)
Create_List_Dialog = List(Ret-1)
flag = 1
If Create_List_Dialog = "" Then
flag = 1
End if
Loop
End Function

'USAGE of the above code:
domains = Array("Yahoo Mail","G Mail","Rediff Mail","Hot Mail","Sify Mail","EXITFROMTEST")
OUTPUT = Create_List_Dialog("MAIL LOGIN", "SELECT APPLICATION", domains)
msgbox OUTPUT
'Find the Output of the above code: