Scripts for Ascending order in qtp.

Answers were Sorted based on User's Feedback



Scripts for Ascending order in qtp...

Answer / mahesh.k

a=array(1,5,6,3,10)
For i=0 to 4
For j=0 to 4
If a(i)<a(j) Then
t=a(i)
a(i)=a(j)
a(j)=t
End If

Next

Next
For i=0 to 4
print a(i)

Next

Is This Answer Correct ?    18 Yes 8 No

Scripts for Ascending order in qtp...

Answer / ekapop techawanto (scnyl)

The best way I found in case of your data sorting consists
of character and number, you may use Excel feature to
support this as following on:

'+++++++++++++++++++
Public Sub SCNYL_SortDataTest()
Const xlAscending = 1 'represents the sorting type 1 for
Ascending 2 for Desc
Const xlGuess = 0
Const xlTopToBottom = 1
Const xlSortNormal = 0
Const iCOLIDX_VALUE = 1 ' Set to Column "A"
Dim oExcel
Dim oWB
Dim oSheet
Dim oRange
Dim asInfo
Dim lRowIdx
Dim lMaxRows
Dim sColName

' Sample data
sValue = "eowos,bweoww, weoeos,ewsow,acc,bzaow,ceoes,
jaow, wwwowam, waosw, 1124,wowasdd, 56, 32,62,108"

' Classified to Array collection
asInfo = Split(sValue, ",")

' Refered to Excel Object
Set oExcel = CreateObject("Excel.Application")

' To make sure Excel Application already installed
If oExcel Is Nothing Then
' Clean Array Object
Erase asInfo
Exit Sub
End If

' Added a new the Workbook object
Set oWB = oExcel.Workbooks.Add

' Ignored all message window displays
oExcel.DisplayAlerts = False

Set oSheet = oWB.Worksheets(1)

' Get the Maximum of Array Object Boundary
lMaxRows = UBound(asInfo)
For lRowIdx = 0 To lMaxRows
' Loaded your data to Excel Sheet
oSheet.Cells(lRowIdx + 1, iCOLIDX_VALUE).Value =
Trim(asInfo(lRowIdx))
Next

' Set Excel Colum at "A"
sColName = "A1:A" & (lMaxRows+1)
oSheet.Range(sColName).Sort oSheet.Range("A1"),
xlAscending, , , , , , xlGuess, 1, False, xlTopToBottom, ,
xlSortNormal

' Clean Array Object
Erase asInfo

' If you'd like to array collection, you should
uncomment for the Array operation.
'ReDim Preserve asInfo(lMaxRows)
For lRowIdx = 0 To lMaxRows
With oSheet
'asInfo(lRowIdx) = .Cells(lRowIdx + 1,
iCOLIDX_VALUE).Value
Print .Cells(lRowIdx + 1,
iCOLIDX_VALUE).Value
End With
Next

' Not Save any thing for this Excel
With oWB
.Saved = False
.Close
End With
oExcel.Quit

' Restore memory allocation
Set oRange = Nothing
Set oWB = Nothing
Set oExcel = Nothing
'Erase asInfo
End Sub

'//// Main ////
Call SCNYL_SortDataTest()

Is This Answer Correct ?    6 Yes 0 No

Scripts for Ascending order in qtp...

Answer / vikas choubey

for i = UBound(appArray) - 1 To 0 Step -1
for j= 0 to i
if appArray(j)>appArray(j+1) then
temp=appArray(j+1)
appArray(j+1)=appArray(j)
appArray(j)=temp
end if
next
next

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More QTP Interview Questions

what difference between runtime object and text object and what property they have. whether they have same properties or different properties.

0 Answers   Intel, Satyam,


How we test web based application by using QTP

0 Answers  


how to write script in qtp(vbscript)..i mean with out application deployed..and how to call script1 into script2?

2 Answers  


What is the extension of script and object repositary files?

2 Answers  


please give me the code for doing retesting of gmail login page using functions so the function has to give the value

0 Answers  






when we apply the daily build each and every day,the property may change in the application.so that the created script is not reusable in winrunner and qtp.for ex for date field it is taken dtpicker.at another time it is taken some other name.how can i solve it.

0 Answers  


pls guys understand this is question CAREFULLY,,, interviwer asks can u write test case for ATM m/c..i told, insert card enter pw...like this,,but interviwer not happy with that...ur not going to atm center? in ur office system ur testing ATM M/c...why ..how to test? what is the process?

1 Answers   Accenture,


whenever U using QTP,Test Director, Why we using separate Bug tracking tool?

0 Answers  


Explain about Table and DB Checkpoints?

1 Answers   Crea,


I have written a code to fetch values fro access db and place in the fields. Iam using GetROProperty to fetch runtime values. Now i want to add runtime values to the access db in field v3. please help me. Its not writting in the db. Option explicit Dim con,rs,db,c Set con=createobject("adodb.connection") Set rs=createobject("adodb.recordset") con.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=D:\Sales.mdb" rs.open "select * from tax",con Do while not rs.eof Browser("Sales Tax Calculator").Page("Sales Tax Calculator").WebEdit("incost").Set rs.fields("v1") Browser("Sales Tax Calculator").Page("Sales Tax Calculator").WebEdit("intax").Set rs.fields("v2") c=Browser("Sales Tax Calculator").Page("Sales Tax Calculator").WebEdit("outtax").GetROProperty("value") rs.MoveNext print c Loop Do while not rs.EOF rs.EditMode rs.Fields("v3").Value="3" rs.Update rs.MoveNext Loop Set rs=nothing Set con=nothing

0 Answers  


How do we run a test from the 3rd row of the datatable in QTP? Leaving the first two rows we need to test AUT from 3rd row to n'th row.

3 Answers   Virtusa,


How to add multiple values in rows, under a single column of a run time datatable?

3 Answers   NIIT,


Categories