Solved

Select item in combo box using the text property

Posted on 2007-11-24
4
164 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yes. That, too, would do it.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 35
VBA color chart bars 12 64
vb6 connector to SQL Server 2 32
Copy a row 12 52
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now