Form4.vb

 Public Class Form4
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents cboxCat As System.Windows.Forms.ComboBox
    Friend WithEvents txtSearch As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents ListView1 As System.Windows.Forms.ListView
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Label14 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form4))
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.cboxCat = New System.Windows.Forms.ComboBox()
        Me.txtSearch = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.ListView1 = New System.Windows.Forms.ListView()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.Label14 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(8, 96)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(416, 16)
        Me.Label5.TabIndex = 0
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 72)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(104, 16)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Search Result :"
        '
        'cboxCat
        '
        Me.cboxCat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboxCat.Items.AddRange(New Object() {"First Name", "Sex", "Email"})
        Me.cboxCat.Location = New System.Drawing.Point(96, 40)
        Me.cboxCat.Name = "cboxCat"
        Me.cboxCat.Size = New System.Drawing.Size(120, 21)
        Me.cboxCat.TabIndex = 2
        '
        'txtSearch
        '
        Me.txtSearch.Location = New System.Drawing.Point(96, 16)
        Me.txtSearch.Name = "txtSearch"
        Me.txtSearch.Size = New System.Drawing.Size(120, 20)
        Me.txtSearch.TabIndex = 1
        Me.txtSearch.Text = ""
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(8, 40)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(80, 16)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Browse By :"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(8, 16)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(80, 16)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Search Text :"
        '
        'ListView1
        '
        Me.ListView1.Location = New System.Drawing.Point(8, 120)
        Me.ListView1.MultiSelect = False
        Me.ListView1.Name = "ListView1"
        Me.ListView1.Size = New System.Drawing.Size(416, 97)
        Me.ListView1.TabIndex = 0
        Me.ListView1.View = System.Windows.Forms.View.SmallIcon
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.SystemColors.Control
        Me.Button1.Location = New System.Drawing.Point(24, 224)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 3
        Me.Button1.Text = "Search"
        '
        'Button2
        '
        Me.Button2.BackColor = System.Drawing.SystemColors.Control
        Me.Button2.Location = New System.Drawing.Point(104, 224)
        Me.Button2.Name = "Button2"
        Me.Button2.TabIndex = 4
        Me.Button2.Text = "Cancel"
        '
        'Label14
        '
        Me.Label14.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label14.ForeColor = System.Drawing.Color.Blue
        Me.Label14.Location = New System.Drawing.Point(328, 8)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(104, 72)
        Me.Label14.TabIndex = 0
        Me.Label14.Text = "Search"
        Me.Label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Form4
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.NavajoWhite
        Me.ClientSize = New System.Drawing.Size(440, 253)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label14, Me.Button2, Me.Button1, Me.ListView1, Me.Label5, Me.Label4, Me.cboxCat, Me.txtSearch, Me.Label3, Me.Label2})
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "Form4"
        Me.Text = " Search"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim FN As New OleDb.OleDbCommand()
    Dim Em As New OleDb.OleDbCommand()
    Dim SMF As New OleDb.OleDbCommand()
    Dim Read As OleDb.OleDbDataReader
    Dim Con As New OleDb.OleDbConnection()

    Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\HendraVB6\VB_NET\Address Book\AD.mdb;Mode=ReadWrite;Persist Security Info=False"

        FN.Connection = Con
        FN.CommandType = CommandType.Text
        FN.CommandText = "Select * From AD Where FirstName=?"

        SMF.Connection = Con
        SMF.CommandType = CommandType.Text
        SMF.CommandText = "Select * From AD Where Sex=?"

        Em.Connection = Con
        Em.CommandType = CommandType.Text
        Em.CommandText = "Select * From AD Where Email=?"

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListView1.Clear()

        If (txtSearch.Text.Trim = "") Then

            MsgBox("Please Enter Your Search Text In The TextBox", MsgBoxStyle.OKOnly, "")
            txtSearch.Focus()
            Exit Sub

        End If

        If cboxCat.SelectedIndex = 0 Then

            FN.Parameters.Add("FirstName", Data.OleDb.OleDbType.Variant)
            FN.Parameters("FirstName").Value = txtSearch.Text

            Con.Open()

            Read = FN.ExecuteReader()


            With Read
                While .Read
                    ListView1.Items.Add("       " & .GetValue(0) & "                " & .GetValue(1) & "                " & .GetValue(2) & "                " & .GetValue(3) & "     " & .GetValue(5))
                End While
            End With

            Con.Close()

            Label5.Text = "     ID              LastName                FirstName               Email                   Age"

        End If

        If cboxCat.SelectedIndex = 1 Then

            SMF.Parameters.Add("Sex", Data.OleDb.OleDbType.Variant)
            SMF.Parameters("Sex").Value = txtSearch.Text

            Con.Open()

            Read = SMF.ExecuteReader()

            With Read
                While .Read
                    ListView1.Items.Add("       " & .GetValue(0) & "                " & .GetValue(1) & "                        " & .GetValue(2) & "                " & .GetValue(3) & "            " & .GetValue(6))
                End While
            End With

            Con.Close()

            Label5.Text = "     ID              LastName                FirstName               Email                   Male"
        End If

        If cboxCat.SelectedIndex = 2 Then

            Em.Parameters.Add("Email", Data.OleDb.OleDbType.Variant)
            Em.Parameters("Email").Value = txtSearch.Text

            Con.Open()

            Read = Em.ExecuteReader()

            With Read
                While .Read
                    ListView1.Items.Add("       " & .GetValue(0) & "                " & .GetValue(1) & "                        " & .GetValue(2) & "                " & .GetValue(3))
                End While
            End With

            Con.Close()

            Label5.Text = "     ID              LastName                FirstName               Email"
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class

Project Homepage: