Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


API Search of itemdata on combobox and listbox

Posted on 2003-11-03
Medium Priority
Last Modified: 2013-12-25
I've used an API call to SendMessage using the LB_FINDSTRINGEXACT or CB_FINDSTRING to search a listbox or combo box.  It there a corresponding ability to search the itemdata field instead of the list field?  Right now I'm just using a for-next loop to search it and was wondering it that was the best approach.
Question by:rkbcpi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Expert Comment

ID: 9673353
LVL 48

Expert Comment

ID: 9673365
Its the fastest

Another would be loop through all the Entries and select the ListIndex OF the Itemdata your looking for

LVL 48

Expert Comment

ID: 9673409
Private Const LB_GETITEMDATA = &H199
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 9673685
I looked at LB_GETITEMDATA earlier and it looks like it returns the itemdata if you supply the index.  What I wanted to know was if there was an API that would behave like the SendMessage using the LB_FINDSTRINGEXACT, but which searched the itemdata entries of a list/combo box and returned the index of the matching entry.  I am currently using a look, but was looking for something that might be a little more efficient.
LVL 48

Accepted Solution

Mikal613 earned 375 total points
ID: 9675758
Your Gonna have to do it the olod fashioned way

Public Function SearchByItemData (ItemData as long) as Integer
  Dim I as Long
  For i = 0 to Combo.ListCount

     If Combo.item(i).Itemdata = Itemdata
          SearchByItemData  = i
     end if

End Function

Expert Comment

ID: 9676145
This is microsoft example of search using sendmessage, it will return the index of corresponding itemdata

~ fantasy ~
LVL 48

Expert Comment

ID: 9676679
Such API doesn't exist since Windows has no idea what is item data - this is just DWORD, which may be, for example, pointer to some structure. You may create collection with item data as key and item index as data. However, simple loop is the best way to do this.

Author Comment

ID: 9677864
Thanks, that's what I'm doing now.  Just checking to see if there was a better way to do it.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question