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

i am new QTP... please tell me automation frameworks , types & for whiich type of applications frameworks are used & how to generate script in keyword driven framework

1606


i want information about API testing and i want info like how process can be done in company? i want added info like coding ,debugging, desing in c.v ? what should add in c.v for eg banking domin? pls any answer my question?

1604


descriptive program for a yahoo mail that is in yahoo mail suppose check box mailid subject assume it is like this format all things are in webtable the question is suppose some mail ids are there in that mailids i want to select the check box wich is before a@gmail.com and after that i want to click on delete button

1806


Define object spy ?

559


What are the different attributes used with regular expression?

549






What is the pros and cons between QTP and Rational Robot

3281


if our qtp vb Script may be Currepted then What we want do?

1482


how did u use automating testing tools in ur job?

1483


Shall we add Local Repository to shared object repository,if yes,how we add

5686


How can I import environment from a file on disk?

536


I have some real time based question.. 1.what are the challenges you have faced in your current project. 2.what are the bugs you found in your current project. 3.what are the strategies you follow to convert manual test cases into automation test cases. 4.how QTP identify two different browsers. 5. When you create a function library and share object repository what are the problems you have faced 6. How to solve the tool tip problem 7.what are the interesting bug you have found in your current project. 8.what is your daily work as a automation test engg. 9. how to create a weekly status report. 10. how many test cases you write,review and execute per day. 11.what are the uses of SQL in automation. 12.How to retrieve the data in html through vb script. 13.If application is very slow how to test the application in qtp.

3567


If an application name changes frequently i.e while recording it has the name, in this case, how do qtp handles?

583


banking project description for software tester

7020


How can I find out the cursor position through QTP suppose I am keep tabbing(Pressing the tab key continuously) and stoped at a position Now I want to find out where the cursor position is

6300


What Folder Structure following in Keyword Driven Frame work?

2282