Solved

combo box first displayed item

Posted on 2004-04-13
4
194 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 20 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 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