[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

combo box first displayed item

Posted on 2004-04-13
4
Medium Priority
?
198 Views
Last Modified: 2010-05-02
Hi all,
I'd like to know how can I set a particular string as the default item into a combo box (VB 6).

I use a combo box with Style property = 2 (i.e. a dropdown list) to display an ORDERED list of string coming from a db field.
During a search process, the user should choose one of them but he could not choose it at all (because it's not a necessary clause in the criteria), so I manually added to the list the word 'ANY'.
Well, since the combo list is ordered ANY does not appear at the first index and the first cell of the combo is always blank.

So, 2 questions:

I need to have an ordered combo where the first voice is always ANY and ANY must be visible as first element also without any selection on the combo.
Is it possible and how ? (I cannot do this through setting Text property since it's read only)

If I need to know the index number of a given element (string), which function returns it ?



Thanks for any kind of help.
Best,
Irene
0
Comment
Question by:new_irene
[X]
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
4 Comments
 
LVL 1

Accepted Solution

by:
prgmrdave earned 80 total points
ID: 10814444
I like to use something like "(Any)", in parentheses, because the parentheses sort ahead of any alphabetic characters.

You can cause it to be selected initially using:

cboSearch.ListIndex = 0

There is no function to tell you the index of a given string; you have to search for it:

For I = 0 To cboSearch.ListCount - 1
    If cboSearch.List(I) = sTerm Then
        bFoundIt = True
        Exit For
    End If
Next I

Hope this helps,

David
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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 While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 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