SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    May 2006
    Location
    India
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Count of items in dropdown

    Hi All,
    Can u please tell me how to get the count of items in a dropdown list?
    I have tried the method "BuiltIn.GetListCount(List)" to get the count.
    But unable to proceed. An error "Type mismatch" is displayed. Can you tell how to get the count using the above method with a sample code in VBscript?

    Regards,
    Revathy

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Location
    Las Vegas
    Posts
    473
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Count of items in dropdown

    To get the number of the dropdown items, it is better to use the "wItemCount" property of the object.

    As far as I understand, you pass the dropdown control to the BuiltIn.GetListCount function.
    The first parameter of the function should be a string containing the list of items separated by a character specified in the second (Delimiter) parameter of this function. The cause of the problem is that you pass an object (that is not a string) to the "GetListCount" method.

    If your "List" variable is a reference to the dropdown object, you can use the "wItemList" property to get the list of items as a string:
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> // JScript
    counter = BuiltIn.GetListCount(List.wItemList);</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Atanas

  3. #3
    Member
    Join Date
    May 2006
    Location
    India
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Count of items in dropdown

    Hi Atanas,

    Thanks for the reply. I have already seen the code for Jscript in some other query. But I want code in VB script and I have also mentioned that explicitly in my query.
    Also in the statement "BuiltIn.GetListCount(List)" , the list refers to the dropdown and I have also checked whether that item exists through "If List.exists = true" code.
    The problem is when I try to execute the script by assigning the above builtiin statement to a variable, the script execution gets stopped by saying " Type mismatch"

    Regards,
    Revathy

  4. #4
    Member
    Join Date
    May 2006
    Location
    India
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Count of items in dropdown

    Hi
    Also I face the same problem in the code
    "BuiltIn.GetListItem(List, i)"

    Regards,
    Revathy

  5. #5
    Senior Member
    Join Date
    Oct 2004
    Location
    Las Vegas
    Posts
    473
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Count of items in dropdown

    Hi Revathy,

    Also in the statement "BuiltIn.GetListCount(List)" , the list refers to the dropdown
    <font size="2" face="Verdana, Arial, Helvetica">The first parameter passed to this method must be a list of items as a string and the second parameter(optional) must be the delimiter used to delimit the list items.

    Here are the sample scripts in VBScript:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> ' VBScript
    ' counter
    counter = BuiltIn.GetListCount(List.wItemList, List.wListSeparator)
    ' third item of the list
    Item = BuiltIn.GetListItem(List.wItemList, 2, List.wListSeparator))</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">To learn more about the BuiltIn.GetListCount and BuiltIn.GetListItem method please read the corresponding help topics of TestComplete help system.

    As I mentioned in my previous post, it's better to use native methods and properties of the dropdown object to work with its items.
    Following is a sample script demonstrating how to use the wItemCount and wItem properties:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> ' VBScript
    ' counter
    counter = List.wItemCount;
    ' third item of the list
    item = List.wItem(2)</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Atanas

  6. #6
    Member
    Join Date
    May 2006
    Location
    India
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Count of items in dropdown

    Thanks a lot Atanas,
    The code worked well.

    Thanks,
    Revathy

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:49 AM.

Copyright BetaSoft Inc.