write vb script code to delete the duplicate values in an
array.

Answer Posted / jay prakash

There are many ways this script can be written.
One simple algo which i followed was:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''Script Starts Here'''''''''''''''''''''''''''''''

Option Explicit

Dim i, j, k, aMyArr, aNewArr( ), iNewIndex, iNewLim, bFlag

bFlag = 0

aMyArr = Array("AA","BB","AA", "BB" )

iNewIndex = UBound(aMyArr)

ReDim aNewArr(0)
aNewArr(0) = aMyArr(0)

For i=0 To UBound(aMyArr)

iNewLim = UBound(aNewArr)

For j = 0 To iNewLim
If aMyArr(i) = aNewArr(j) Then
bFlag = 0
Exit For
Else
bFlag = 1
End If
Next

If bflag = 1 Then
k=iNewLim+1
ReDim Preserve aNewArr(k)
aNewArr(k)=aMyArr(i)
End If

Next

' To display the new array...
For i = 0 to UBound(aNewArr)
msgbox aNewArr(i)
Next


Erase aMyArr
Erase aNewArr

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''Script Ends Here'''''''''''''''''''''''''''''''

Please let me know if it satisfies ur query.

Is This Answer Correct ?    9 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how we connect 1. qtp9.2 to the quality center9.0? 2. Load runner8.0 to the quality center9.0

1573


How to Test the mainframe application?

1911


What are the two types of repositories available, explain them?

671


How to add verification steps to tests?

9266


Explain about the quicktest professional (qtp) automation object model?

660






How do I lauch my test website using code from qtp in different environmet, uat and PPTE?

1565


In a flight window we have to enter the name and meal request for every passenger.In that window if we give Total passengers=1 then the Psngr1 name field and psngr1 meal request field will reflects.if we give Total passengers=2 then Psngr1 name field and psngr1 meal request field,Psngr2 name field and psngr2 meal request field will reflects and so on.if total psngrs=100 then will we capture all the fields for the psngrs to Automate the app how we can handle this scenerio thru Descriptive programming?

1552


explain how to write vb script in qtp?when will you write own script?

1953


hi i have completed my b.tech in cse stream. now i am working in an organisation in testing department. i want do sap course but i dnt know which module will boost my career can anyone suggest me which is good for my career

2039


How the exception handling can be done using quicktest professional?

635


In qtp, how you can get the last character from a string?

640


If a button named "CLICK" is recorded in low level recording mode , what will be the values stored for "name" property of that button in object repository ?

1841


How to interact tool & application build in QTP?

1555


Which recording modes need more memory?

664


When using descriptive programming?

729