Solved

Combo box problem

Posted on 2004-09-14
2
243 Views
Last Modified: 2010-04-23
Hi Experts, I have populated the combobox (cbo1) with values (0-9). I have a textbox (txtValue) having a value of 5. I want to find out the location of the text value with respect to the combo box.

How could I achieve this in VB.NET?

TIA.
0
Comment
Question by:bpyeo
[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 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 50 total points
ID: 12052128
for i = 0 to ComboBox1.Items.Count -1
if(ComboBox1.Items[i] == textBox1.Text)
{
MEssageBox.Show("The text is at the position" : i)
}

NExt i
0
 
LVL 19

Expert Comment

by:Desp
ID: 12052279
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        MessageBox.Show("Position is "  + GetIndex(txtValue.Text))
End Sub

Private Function GetIndex(ByVal text As String) As Int32
        Dim i As Int32
        If cbo1.Items.Contains(txtValue.Text) Then
            For i = 0 To cbo1.Items.Count-1
                If text = cbo1.Items.Item(i) Then
                    Return i
                End If
            Next
        End If
End Function
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

626 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