Video Lectures‎ > ‎

Search Items in Listbox

This is the tutorial of Visual Basic 2010 or 2008, How to make search items of a listbox or compare them with textbox
This is the tutorial of Visual Basic 2010 or 2008, How to make search items of a listbox or compare them with textbox
The Video is in English and Urdu!
Same coding can run Visual Basic 2008
1. Open Visual Basic 2010 or 2008
2. Click new Project in file menu
3. Draw 2 listboxes, 2 textboxes, 2 buttons
4. Enter coding
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox2.Items.Clear()
        Dim count As Integer = (ListBox1.Items.Count - 1)
        Dim words As String
        For a = 0 To count
            words = ListBox1.Items.Item(a)
            If InStr(words.ToLower, TextBox2.Text.ToLower) Then
                ListBox2.Items.Add(words)
            End If
        Next
    End Sub
End Class
5. Run your Program
Comments