Fixed Combo Demo

Fixed Combo Demo

1. Create a standard exe project.

2. Place a label with caption "Enter Text to Display in Combo box from its list:

3. Place a Textbox under than label.

4. Under Textbox place a comand button with caption "Show Text"

5. Place a Combo Box Under that Button and set its style property to 2

6. In list Property of combo box specify following items:-
Text1
Text2
Text3
Text4
Text5

Now add code to the click evevnt of command button.

Private Sub Command1_Click()
On Error GoTo nferr
Combo1.ListIndex = -1
Do While Not Combo1.ListIndex = Combo1.ListCount
   If Combo1.Text = Text1.Text Then
       Exit Do
   Combo1.ListIndex = Combo1.ListIndex + 1
   End If
Loop
nferr:
If Err.Number <> 0 Then
   MsgBox "Text specified not found in the list", vbExclamation
   Text1.Text = ""
   Combo1.ListIndex = -1
End If
End Sub

You might also like...

Comments

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”