How to Search Items in Listbox Using VB.Net

0
1768

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.[vbnet]Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadWith ListBox1.Items
    .Add(“Andrew Braza”)
    .Add(“Christian Pecson”)
    .Add(“Jesler Ergino”)
    .Add(“Marcus Ibalio”)
    .Add(“Aevahn Perucho”)
    .Add(“John Palo”)
    .Add(“Markfil Baldomero”)
    .Add(“Jesriel Agita”)
    .Add(“Carlie Golez”)
    .Add(“Raffy Buendia”)
    .Add(“Karen Oquendo”)
    .Add(“Ella Diaz”)
    .Add(“Sj Cabrera”)
    .Add(“Argie Dela Cruz”)
    .Add(“Mc Laurence”)
    .Add(“Ej Fajardo”)
    .Add(“Cj Dela Cruz”)
    .Add(“Paulo Manalili”)
    .Add(“Steven Sese”)

    End With
    End Sub

    [/vbnet]

  • Then, add this code to the Button.
    [vbnet]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim count As Integer = (ListBox1.Items.Count – 1)
    Dim words As String
    For search = 0 To count
    words = ListBox1.Items.Item(search)
    If InStr(words.ToLower, TextBox1.Text.ToLower) Then
    ListBox1.SelectedItem = words
    End If
    Next
    End Sub[/vbnet]
  • 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:

 

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.