Top 3 Most Viewed Youtube Videos - Computer Programming

Free Source Code: Top 3 Most Viewed Youtube Videos - Computer Programming


1. Programming in Visual Basic .Net How to Connect Access Database to VB.NET
https://youtu.be/cwDqjmSmtMQ


2. Visual Basic .NET : Search in Access Database - DataGridView BindingSource Filter (Part 1/2)
https://youtu.be/UoT2oava9ns


3. Visual Basic .NET : Search in Access Database - DataGridView BindingSource Filter (Part 2/2)
https://youtu.be/e5Dvkw7moWg


View the full playlist: https://www.youtube.com/playlist?list=PLJiGI-KZnz3T9IMIAs1AyjgQ3k0XF2Evb


Free Source code by iBasskung


Option Explicit On

Option Strict On


Public Class Form1


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

        'TODO: This line of code loads data into the 'Your_DatabaseDataSet.Table1' table. You can move, or remove it, as needed.

        Me.Table1TableAdapter.Fill(Me.Your_DatabaseDataSet.Table1)


        With DataGridView1

            .ClearSelection()

            .ReadOnly = True

            .MultiSelect = False

        End With


        Dim colors() As String = [Enum].GetNames(GetType(KnownColor))


        cboDfColor.Items.AddRange(colors)

        cboAltColor.Items.AddRange(colors)


        Me.reset()


    End Sub


    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

        Table1BindingSource.MovePrevious()

    End Sub


    Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click

        Table1BindingSource.AddNew()

    End Sub


    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

        Table1BindingSource.MoveNext()

    End Sub


    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click


        On Error GoTo SaveErr

        Table1BindingSource.EndEdit()

        Table1TableAdapter.Update(Your_DatabaseDataSet.Table1)


ErrEx:

        Exit Sub

SaveErr:

        MsgBox("Error Number " & Err.Number & vbNewLine &

               "Error Description " & Err.Description, MsgBoxStyle.Critical,

               "Reset Error!")

        Resume ErrEx


    End Sub


    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click


        If MessageBox.Show("Are you sure", "Delete Record", MessageBoxButtons.YesNo,

                           MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) =

                       Windows.Forms.DialogResult.Yes Then

            Table1BindingSource.RemoveCurrent()

        End If


    End Sub


    Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click


        Dim msg As String = "Do you want to Exit?"

        Dim title As String = "Exit Application"


        If MessageBox.Show(msg, title, MessageBoxButtons.YesNo,

                           MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) =

                       Windows.Forms.DialogResult.Yes Then

            Me.Close() 'End

        End If


    End Sub


    Private Sub cboDfColor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDfColor.SelectedIndexChanged

        cboDfColor.BackColor = Color.FromName(cboDfColor.SelectedItem.ToString())

        txtSearch.Select()

    End Sub


    Private Sub cboAltColor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAltColor.SelectedIndexChanged

        cboAltColor.BackColor = Color.FromName(cboAltColor.SelectedItem.ToString())

        txtSearch.Select()

    End Sub


    Private Sub lblReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblReset.Click


        On Error GoTo ErrRe


        txtSearch.Select()

        Table1BindingSource.Filter = Nothing



        With DataGridView1

            .ClearSelection()

            .ReadOnly = True

            .MultiSelect = False

            .DataSource = Table1BindingSource

        End With


        Me.reset()


ErrEx:

        Exit Sub

ErrRe:

        MsgBox("Error Number " & Err.Number & vbNewLine &

               "Error Description " & Err.Description, MsgBoxStyle.Critical,

               "Reset Error!")


        Resume ErrEx


    End Sub


    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click


        On Error GoTo SearchErr


        If txtSearch.Text = "" Then

            Call notFound()

            Exit Sub

        Else


            Dim cantFind As String = txtSearch.Text


            Me.dgvFill()


            Table1BindingSource.Filter = "(Convert(ID, 'System.String') LIKE '" & txtSearch.Text & "')" &

                "OR (YourName LIKE '%" & txtSearch.Text & "%') OR (Lastname LIKE '%" & txtSearch.Text & "%')" &

                "OR (Phone LIKE '%" & txtSearch.Text & "%') OR (Email LIKE '%" & txtSearch.Text & "%')" &

                "OR (Facebook LIKE '%" & txtSearch.Text & "%')"


            If Table1BindingSource.Count <> 0 Then


                With DataGridView1

                    .DataSource = Table1BindingSource

                End With


            Else


                Me.notFound()


                MsgBox("--> " & cantFind & vbNewLine &

                       "The search item was not found.",

                       MsgBoxStyle.Information, "Hey Boss!")


                Table1BindingSource.Filter = Nothing


                With DataGridView1

                    .ClearSelection()

                    .ReadOnly = True

                    .MultiSelect = False

                    .DataSource = Table1BindingSource

                End With


            End If


        End If


ErrExit:

        Exit Sub

SearchErr:

        MsgBox("Error Number " & Err.Number & vbNewLine &

               "Error Description " & Err.Description, MsgBoxStyle.Critical,

               "Reset Error!")


        Resume ErrExit


    End Sub


    Private Sub reset()


        Dim txtS As TextBox = txtSearch


        With txtS

            .Text = ""

            .Select()

            .BackColor = Color.LightCyan

        End With


        cboDfColor.SelectedItem = "MistyRose"

        cboAltColor.SelectedItem = "Gold"


        cboDfColor.BackColor = Color.LightCyan

        cboAltColor.BackColor = Color.LightCyan


        If DataGridView1.DataSource Is Nothing Then

            Exit Sub

        End If


        Dim dgv1 As DataGridView = DataGridView1


        With dgv1

            .RowsDefaultCellStyle.BackColor = Color.FromName(cboDfColor.SelectedItem.ToString())

            .AlternatingRowsDefaultCellStyle.BackColor = Color.FromName(cboAltColor.SelectedItem.ToString())

        End With


    End Sub


    Private Sub dgvFill()


        txtSearch.BackColor = Color.LightBlue


        If DataGridView1.DataSource Is Nothing Then

            Exit Sub

        End If


        Dim myDGV1 As DataGridView = DataGridView1


        With myDGV1

            .RowsDefaultCellStyle.BackColor = Color.FromName(cboDfColor.SelectedItem.ToString())

            .AlternatingRowsDefaultCellStyle.BackColor = Color.FromName(cboAltColor.SelectedItem.ToString())

        End With


    End Sub


    Private Sub notFound()


        Dim txtS As TextBox = txtSearch


        With txtS

            .BackColor = Color.White

            .Select()

            .SelectAll()

        End With


        If DataGridView1.DataSource Is Nothing Then

            Exit Sub

        End If


        Dim dgv As DataGridView = DataGridView1


        With dgv

            .RowsDefaultCellStyle.BackColor = Color.White

            .AlternatingRowsDefaultCellStyle.BackColor = Color.White

        End With


    End Sub


End Class


Comments