How to find an item in a combo box

Hello I have a  string value.

Is there any way of finding the string value in a combo box and setting that item as the item that is displayed. Would anybody have any code to do this.

Thanks

Anwar
anwarmirAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RonaldBiemansCommented:
something like this
        ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf("yourstring")
0
willcode4coffeeCommented:
I think that if the value is in the combo box list you can just set the value and it will match it...just as if you typed it in.

ComboBox1.Value = "YourString"

M@
0
koruzicaCommented:
Private Sub searchCombobox1(ByVal strSearch As String)
        For Each itm As String In ComboBox1.Items
            'lets give priority to: begins with...
            If itm.StartsWith(strSearch) Then
                ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(itm)
                Exit Sub
            End If
        Next

        For Each itm As String In ComboBox1.Items
            'ok, we didn't find any first occurances so...
            If itm.IndexOf(strSearch) > 0 Then
                ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(itm)
                Exit Sub
            End If
        Next

    End Sub
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

karthikeyanTPCommented:

Try this

  cboBox1.SelectedIndex = cboBox1.FindString("your String here")
0
koruzicaCommented:
Oops, how did i miss that :)

0
karthikeyanTPCommented:
Hai anwarmir,

Does it work?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.