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
What is object repository in qtp?
What are the different types of recovery operation?
How to analyzing test results using quicktest professional (qtp)?
Give me some real time point of way where exactly we can conduct audits?
Can we run test with out adding object in object repository? How it is possible?
Which scripting language used by quicktest professional (qtp)?
How would you directly trigger javascript in a test?
If object is not recognized by qtp but the object is standard object what is your approach?
How to customize qtp?
An action has both shared and local OR associated with it and both have the same object in them. In the test which one will be considered?
Explain the features and benefits of quick test pro(qtp)?
Explain different checkpoints in qtp.
i am a begnner so am learning Error handling :tried using Recovery manager didnt work i want to be able to handle errors , e.g. if while running the test the folwoing does not show up then how can i use the If then else and goto next step in the test, as in many scenarios it does not show up Browser("The Shopping Channel -").Page("The Shopping Channel -_8").Image("easy pay").Click
What is keyword view in qtp?
Explain the check points in quicktest professional?