Selecting second to last item of a list box - 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: Selecting second to last item of a list box (/Thread-Selecting-second-to-last-item-of-a-list-box) |
Selecting second to last item of a list box - janriis - 12-10-2009 Hi all In my VB6 app, I have a list box where I must select a specific item. The item is always the second to last item. I think it is something with itemcount -1, but I am not sure how the syntax is. Anyone ? RE: Selecting second to last item of a list box - nil - 12-10-2009 Hi you can do it with itemcount-1 but i suggest you to select with item text, .select "text" using above statement you need not worry at what index your item is. Thanks RE: Selecting second to last item of a list box - janriis - 12-10-2009 Hi Nilesh If i use .select "text" my script is not dynamic. The items change names for each run, but not position. RE: Selecting second to last item of a list box - nil - 12-10-2009 Code: GetROProperty("items count") 'Returns item count Try this code Thanks RE: Selecting second to last item of a list box - sreekanth chilam - 12-10-2009 @Nilesh: Fyi, Janris issue was with "VbList" not the "WebList" and your solution works fine for WebList. @janris: For VbList object, you can try with the below way. Code: ListItemCount=VbWindow("frmMain").VbWindow("...").VbList("...").GetItemsCount Note: As the Items in VbList are stored from index "0" : If we want to select Last item --> .Select ListItemCount-1 If we want to select Second to Last item--> .Select ListItemCount-2 Hope this would solve your issue. RE: Selecting second to last item of a list box - upadhyay40 - 12-12-2009 Hi Janriss, Whether you try to lake the value with the help of Index property. Thanks' Mahesh |