How to Search Items in Listbox Using VB.Net

0
181

This tutorial is all about How to Search Items in Listbox Using VB.Net. With this tutorial you Search Items in Listbox Using VB.Net easily. So let’s get starte

  • First is open the Visual Basic, Select File on the menu, then click New and create a new project.

  • Then a New Project Dialog will appear. You can rename your project, depending on what you like to name it. After that click OK

  • Design your form like this just like what I’ve shown you below.
    Add a Label, Textbox, Button, and a Listbox from the toolbox.
  • After that add this code to Form1 Load.
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadWith ListBox1.Items
    2. .Add("Andrew Braza")
    3. .Add("Christian Pecson")
    4. .Add("Jesler Ergino")
    5. .Add("Marcus Ibalio")
    6. .Add("Aevahn Perucho")
    7. .Add("John Palo")
    8. .Add("Markfil Baldomero")
    9. .Add("Jesriel Agita")
    10. .Add("Carlie Golez")
    11. .Add("Raffy Buendia")
    12. .Add("Karen Oquendo")
    13. .Add("Ella Diaz")
    14. .Add("Sj Cabrera")
    15. .Add("Argie Dela Cruz")
    16. .Add("Mc Laurence")
    17. .Add("Ej Fajardo")
    18. .Add("Cj Dela Cruz")
    19. .Add("Paulo Manalili")
    20. .Add("Steven Sese")
    21.  
    22. End With
    23. End Sub
  • Then, add this code to the Button.
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. Dim count As Integer = (ListBox1.Items.Count - 1)
    3. Dim words As String
    4. For search = 0 To count
    5. words = ListBox1.Items.Item(search)
    6. If InStr(words.ToLower, TextBox1.Text.ToLower) Then
    7. ListBox1.SelectedItem = words
    8. End If
    9. Next
    10. End Sub
  • Finally Click F5 to run the program.
    Output:

    If you have any comments or suggestion about on How to Search Items in Listbox Using VB.Net, Please Feel Free to contact our webpage.

    Download How to Search Items in Listbox Using VB.Net Code Here

     

     

Other articles you might read also:

 

 

 

 

Facebook Comments
(Visited 203 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here