Solved

Combo box problem

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

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

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 135
vb.net deleting excel sheet in workbook 11 55
VB .net 2010 Byte array 2 22
VB.net SQL Connection String Read Only 4 19
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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