Pages

Friday, March 30

Find distinct unique values from array using QTP/vbscript

Hello Friends,

In this post, we will see, how to get unique/distinct values from an array.
We will do that using very useful and optimum feature of QTP - Dictionary Object.

Here is the code--

Dim objDict, oldArray, val
oldArray = Array ("11", "21", "11", "31", "21", "41", "31")

Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare

For each val in oldArray
objDict(val) = val
Next

newArray = objDict.Items

For i=0 to ubound(newArray)
msgbox newArray(i)
Next

...n done!!!

Plz do post your queries/comments...

37 comments:

  1. Nice Code. It is reaching our expectations without any updates

    ReplyDelete
  2. Hi,

    Need small change in below part of above mentioned code...

    Incorrect One :
    For i=0 to ubound(newArray)
    msgbox newArray(i)
    Next

    Correct One :
    For i=0 to ubound(newArray)-1
    msgbox newArray(i)
    Next

    ReplyDelete
  3. objDict.CompareMode = vbTextCompare

    what did this code ?

    ll it run without this?

    ReplyDelete
  4. If you do without the Comparemode = vbTextCompare then the will be VbBinaryCompare. so any time if objDict found "11" & "11" binary values are different it will take as new value and you will get "11" 2 times.

    So to avoid that any point of time tell obDict to compare text wise.

    ReplyDelete
  5. How can you get items that only appear once. Meaning "41" only in the above mentioned array?

    ReplyDelete
  6. @Deepak, you're wrong Ubound returns the highest index of an array. So the code above is correct.

    ReplyDelete
  7. For each val in oldArray
    objDict(val) = val
    Next

    What the above code is doing?

    ReplyDelete
  8. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…

    Java training in Chennai | Java training in Bangalore

    Java online training | Java training in Pune

    ReplyDelete
  9. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    advanced excel training in bangalore | Devops Training in Chennai

    ReplyDelete
  10. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    python course in pune | python course in chennai | python course in Bangalore

    ReplyDelete


  11. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.


    AWS Training in BTM Layout |Best AWS Training in BTM Layout

    AWS Training in Marathahalli | Best AWS Training in Marathahalli

    ReplyDelete
  12. Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. 

    angularjs Training in btm

    angularjs Training in electronic-city

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    ReplyDelete
  13. Thanks for sharing such an informative post with us. I hope you will share more such post. Please keep sharing.
    Apple Service center in Ameerpet, Hyderabad
    Best Laptop Service center in Ameerpet, Hyderabad

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. thanks for Sharing such an Awesome information with us.

    I learned World's Trending Technology from certified experts for free of cost.i Got job in decent Top MNC Company with handsome 14 LPA salary, i have learned the World's Trending Technology from Python training in pune experts who know advanced concepts which can helps to solve any type of Real time issues in the field of Python. Really worth trying Freelance seo expert in bangalore

    ReplyDelete
  16. Thanks for sharing information with us.This post is very attractive and useful for the users.The content provided is relevant to the topic.One can gain knowledge and have basic understanding by reading this blog.
    data science training institutes in bangalore

    ReplyDelete
  17. Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. 111 niche blogcomments

    ReplyDelete
  18. It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!Your blog has very useful information about this technology which i am searching now, i am eagerly waiting to see your next post as soonI just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!Java training in Chennai

    Java Online training in Chennai

    Java Course in Chennai

    Best JAVA Training Institutes in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Training

    Java Online Training

    ReplyDelete
  19. Thanks for sharing information with us.This post is very attractive and useful for the users.The content provided is relevant to the topic.One can gain knowledge and have basic understanding by reading this blog.

    angular js training in chennai

    angular training in chennai

    angular js online training in chennai

    angular js training in bangalore

    angular js training in hyderabad

    angular js training in coimbatore

    angular js training

    angular js online training

    ReplyDelete

  20. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.


    Azure Training in Chennai

    Azure Training in Bangalore

    Azure Training in Hyderabad

    Azure Training in Pune

    Azure Training | microsoft azure certification | Azure Online Training Course

    Azure Online Training

    ReplyDelete
  21. Excellent Blog! I would Thanks for sharing this wonderful content.its very useful to us.This is incredible,I feel really happy to have seen your webpage.I gained many unknown information, the way you have clearly explained is really fantastic.keep posting such useful information.
    Full Stack Training in Chennai | Certification | Online Training Course
    Full Stack Training in Bangalore | Certification | Online Training Course

    Full Stack Training in Hyderabad | Certification | Online Training Course
    Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai
    Full Stack Training

    Full Stack Online Training


    ReplyDelete
  22. Nice post. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated posts…

    AWS Course in Bangalore

    AWS Course in Hyderabad

    AWS Course in Coimbatore

    AWS Course

    AWS Certification Course

    AWS Certification Training

    AWS Online Training

    AWS Training

    ReplyDelete
  23. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    spoken english classes in chennai | Communication training


    ReplyDelete
  24. Am Divya,Am really impressed about this blog because this blog is very easy to learn and understand clearly.This blog is very useful for the college students and researchers to take a good notes in good manner,I gained many unknown information.

    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  25. Great survey, I'm sure you're getting a great response.

    ReplyDelete
  26. Great post. keep sharing such a worthy information.
    Hadoop Training in Chennai

    ReplyDelete
  27. All our top-rated websites supply excellent bonuses for an excellent begin to your online slots expertise. The games themselves all supply excessive payout percentages to provide the greatest return on 카지노사이트 your bet, and cashing out any huge win could be very simple with all popular banking options. If you’re a winner, find a way to|you possibly can} expect any funds to be in your account within hours.

    ReplyDelete
  28. thanks for this valuable information , keep posting and if you are intresting in web development then checkout my full stack classes in satara

    ReplyDelete