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
Solved

Select item in combo box using the text property

Posted on 2007-11-24
4
176 Views
Last Modified: 2010-04-30
I have a combo box that holds titles of different sections of an .ini file. When a selection is made it gets the data from .ini file. The data is then loaded into a Mshflexgrid. Users can add and rename sections. I have 1 section that cannot be renamed or deleted called "All Materials". I never know the index as it can change when sections are added or deleted
How can i programically select "All materials"
0
Comment
Question by:isnoend2001
  • 2
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 20343284
Not sure how you want to use it, but let's start with this

Dim l As Integer
For l = 0 To Combo1.ListCount - 1
    If Combo1.List(l) = "All Materials" Then
        Combo1.Text = Combo1.List(l)
        Exit For
    End If
Next l
0
 

Author Closing Comment

by:isnoend2001
ID: 31410778
Thank you
I modified it to select the item and it works.
For l = 0 To Combo1.ListCount - 1
    If Combo1.List(l) = "All Materials" Then
        'Combo1.Text = Combo1.List(l)
Combo1.ListIndex = 1
        Exit For
    End If
Next l
0
 

Author Comment

by:isnoend2001
ID: 20343316
Dim l As Integer
For l = 0 To Combo1.ListCount - 1
    If Combo1.List(l) = "All Materials" Then
        'Combo1.Text = Combo1.List(l)
 Combo1.ListIndex = 1
        Exit For
    End If
Next l
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20343468
Yes. That, too, would do it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

828 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