Solved

Combo box problem

Posted on 2004-09-14
2
232 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
2 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 50 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

11 Experts available now in Live!

Get 1:1 Help Now