Scripts for Ascending order in qtp.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the qtp testing process?

819


How to creating an output value using quicktest professional?

755


How to attach a file to TD?

882


Hi we are using QTP9.0 for Seibel Application and this seibel application will give you a popup messagebox which is of web , so qtp takes 3 mins to recognize the messagebox and to click on it , we have more number of messageboxes like this . please suggest me some solution

1903


desribe a situation where u faced a stressful situation and how did u cope with it

1650


banking domain description for software tester for interview

3689


In QA Testing when do you use Loadrunner vs QTP? What are the main differences between those two tools? Explain the purpose with real world scenario examples...In advance thank you!!!

2647


Hai anyone please "Explain about Framework in QTP?"

1865


Write the script to delete the mail which is at 9th,13th and 18th place in INBOX of Gmail ?

1905


What is different command used in command Prompt while using QTP?

2007


What is checkpoints for quicktest professional (qtp)?

805


please any one can explain the keyword driven framework. with gmail example.

1849


I have qtp 9.5 demo ver,I am not able to record the yahoo broeser.so anyone can tell me what setting i have to do in QTP for yahoo brower recording. why its not recognise the object of yahoo browser????

2414


what type of framework u r using in ur organization

1855


How you will rate urself in QTP in the range of 0 to 5

1966