Solved

Combo box problem

Posted on 2004-09-14
2
236 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 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