How to check for duplicate rows/items in table? - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: How to check for duplicate rows/items in table? (/Thread-How-to-check-for-duplicate-rows-items-in-table) Pages:
1
2
|
How to check for duplicate rows/items in table? - Aestival - 08-03-2010 [attachment=479]Hi, I am checking whether there are any duplicate items in my table. However the rows in my table will vary which mean I do not know how many rows I will have in my table unless I do a row count. In this case, I would like to check if I have any duplicate "Level". And in the screenshot(attached), there is duplicate "Level". It should then return a dialog box as an error. So how do I write my code using loop method? thanks RE: How to check for duplicate rows/items in table? - guin.anirban - 08-03-2010 First you count how many rows are there. Get the 1st row value of the "Level" column and compare it with the rest of the values of the same column. If any matches found then no need to proceed further and exit from the function (If you are going to test this one by preparing a function). If no matches found then you get the 2nd row value of the "Level" column and compare it with the rest of the values of the same column. RE: How to check for duplicate rows/items in table? - Aestival - 08-03-2010 Hey thx for ur reply.. Yes, this is what I'm thinking of doing.. but my problem now is I dunno how to compare.. Do you mind providing me with a sample code? thx very much RE: How to check for duplicate rows/items in table? - guin.anirban - 08-03-2010 See the belog script and let me know whether this helps you. Code: intRowCnt = Object.Table().RowCount RE: How to check for duplicate rows/items in table? - Aestival - 08-03-2010 I'm not sure if I did it correctly. But when I run my test nth happen.. here's my code.. (my table row default value is 1) I dunno where is the problem.. Code: nTotalRow = Browser("bwTPeSA").Page("bwTPeSA.pgMySub").WebTable("bwTPeSA.mySub.tblSubjects").RowCount RE: How to check for duplicate rows/items in table? - guin.anirban - 08-03-2010 .............................................................................................. I did one mistake in the script. I didn't use the Exit Function statement when the row count is 0 or 1 as that point of time we don't need to compare. Code: intRowCnt = Object.Table().RowCount RE: How to check for duplicate rows/items in table? - Aestival - 08-03-2010 I still cnt get it.. nth happened.. is there sth wrong with my code? RE: How to check for duplicate rows/items in table? - guin.anirban - 08-03-2010 As you told that in that table row default value is 1. So if we consider row count as 1 then no need compare and even though you are trying to access the function then it will return False. The function is designed for returning only the True or False value. RE: How to check for duplicate rows/items in table? - Aestival - 08-03-2010 i dun get what u mean.. default value is 1 mean even without adding anything to the table, the rows count is alrdy 1 in the first place. RE: How to check for duplicate rows/items in table? - guin.anirban - 08-03-2010 Hi Aestival, ok i got your point. You add few rows in the table and use the latest function and pass the rowcount to that function and see what the function is returning? |