Solved

Select item in combo box using the text property

Posted on 2007-11-24
4
183 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
[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
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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