Programming for Everybody: April 2025

How to display data excel sheet in userform VBA Using navigation buttons




Dim row_num As Integer
 Private Sub CommandButton2_Click()
row_num = Sheet5.range("A2").End(xlUp).Row + 1
Me.idtxt = Sheet5.Cells(row_num, 1)
load_data
End Sub

Private Sub load_data()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet5")
Dim i As Long
For i = 1 To Sheet5.UsedRange.Rows.Count
If idtxt.Text = Sheet5.Cells(i, 1).Value Then
ftxt.Text = Sheet5.Cells(i, 2).Value
ltxt.Text = Sheet5.Cells(i, 3).Value
sporttxt.Text = Sheet5.Cells(i, 4).Value
pointtxt.Text = Sheet5.Cells(i, 5).Value
Exit Sub
Else
ftxt.Text = ""
ltxt.Text = ""
sporttxt.Text = ""
pointtxt.Text = ""
End If
Next i

End Sub

Private Sub CommandButton3_Click()
If row_num < Sheet5.Cells(Rows.Count, 1).End(xlUp).Row Then
row_num = row_num + 1
Me.idtxt = Sheet5.Cells(row_num, 1)
load_data
End If
End Sub

Private Sub CommandButton4_Click()
If row_num > Sheet5.range("A2").End(xlUp).Row + 1 Then
row_num = row_num - 1
Me.idtxt = Sheet5.Cells(row_num, 1)
load_data
Exit Sub

Else
End If
End Sub

Private Sub CommandButton5_Click()
row_num = Sheet5.Cells(Rows.Count, 1).End(xlUp).Row
Me.idtxt = Sheet5.Cells(row_num, 1)
load_data
End Sub

Private Sub UserForm_Click()

End Sub

c# tutorial for beginners: How to connect Microsoft access database to C#

c# tutorial for beginners: Connect access database (connection-insert-update-delete - search in database) with create access database and add images .
Subscribe to @programmingforeverybody
https://www.youtube.com/@programmingcode2025/?sub_confirmation=1
Contents:
Add controls to your form 00:00
Delete last blank row in datagridview 09:26
Browse button 09:42
Create table database 14:21
Add Dataset and relate it with controls 15:37
change columns header text datagridview 20:52
New button 23:16
Format DateTime column in a DataGridView 25:04
Save or update button 26:17
Search button 29:34
Reset button 32:26
Remove button 33:24
Previous button 34:16
Next button 34:48
First button 35:06
Last button 35:25
Close button 35:41

 



Step by step how to Connect SQL server Database with Visual Basic .net with Source code

Public Class Form1

    Private Sub Browse_btn_Click(sender As Object, e As EventArgs) Handles Browse_btn.Click

        OpenFileDialog1.Filter = "Image|*.png;*.jpg;*.bmp"

        If OpenFileDialog1.ShowDialog = DialogResult.OK Then

            pictxt.Text = OpenFileDialog1.FileName

            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)

        Else

            pictxt.Text = ""

            PictureBox1.Image = Nothing

        End If

    End Sub


    Private Sub pictxt_TextChanged(sender As Object, e As EventArgs) Handles pictxt.TextChanged

        If pictxt.Text = "" Then

            PictureBox1.Image = Nothing

        Else

            PictureBox1.Image = Image.FromFile(pictxt.Text)

        End If

    End Sub


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

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

        Me.Table1TableAdapter.Fill(Me.Students3DataSet.Table1)

        DataGridView1.Columns(4).DefaultCellStyle.Format = "MM/dd/yyyy"

        DataGridView1.Columns(0).HeaderText = "ID"

        DataGridView1.Columns(1).HeaderText = "Code"

        DataGridView1.Columns(2).HeaderText = "Name"

        DataGridView1.Columns(3).HeaderText = "Phone"

        DataGridView1.Columns(4).HeaderText = "Date"

        DataGridView1.Columns(5).HeaderText = "Grade"

        DataGridView1.Columns(6).HeaderText = "Class"

        DataGridView1.Columns(7).HeaderText = "Picture"

    End Sub


    Private Sub new_btn_Click(sender As Object, e As EventArgs) Handles new_btn.Click

        Dim row = DirectCast(Table1BindingSource.AddNew(), DataRowView)

        row("rdate") = dtp1.Value

    End Sub


    Private Sub save_btn_Click(sender As Object, e As EventArgs) Handles save_btn.Click

        If (String.IsNullOrEmpty(codetxt.Text)) Then

            ErrorProvider1.SetError(codetxt, "Code Is required")

        Else

            ErrorProvider1.SetError(codetxt, String.Empty)

            For i As Integer = 0 To DataGridView1.Rows.Count - 1

                If codetxt.Text = DataGridView1.Rows(i).Cells(1).Value.ToString And idtxt.Text <> DataGridView1.Rows(i).Cells(0).Value.ToString Then

                    MessageBox.Show("Code Exists Before")

                    Return

                Else

                    Table1BindingSource.EndEdit()

                    Table1TableAdapter.Update(Students3DataSet.Table1)

                End If

            Next

            MessageBox.Show("Data Saved Successfully")

        End If

    End Sub


    Private Sub codetxt_TextChanged(sender As Object, e As EventArgs) Handles codetxt.TextChanged

        If (String.IsNullOrEmpty(codetxt.Text)) Then

            ErrorProvider1.SetError(codetxt, "Code Is required")

        Else

            ErrorProvider1.SetError(codetxt, String.Empty)

        End If

    End Sub


    Private Sub delete_btn_Click(sender As Object, e As EventArgs) Handles delete_btn.Click

        Table1BindingSource.RemoveCurrent()

        Table1TableAdapter.Update(Students3DataSet.Table1)

        PictureBox1.Image = Nothing

    End Sub


    Private Sub first_btn_Click(sender As Object, e As EventArgs) Handles first_btn.Click

        Table1BindingSource.MoveFirst()

    End Sub


    Private Sub next_btn_Click(sender As Object, e As EventArgs) Handles next_btn.Click

        Table1BindingSource.MoveNext()

    End Sub


    Private Sub previous_btn_Click(sender As Object, e As EventArgs) Handles previous_btn.Click

        Table1BindingSource.MovePrevious()

    End Sub


    Private Sub last_btn_Click(sender As Object, e As EventArgs) Handles last_btn.Click

        Table1BindingSource.MoveLast()

    End Sub


    Private Sub close_btn_Click(sender As Object, e As EventArgs) Handles close_btn.Click

        Me.Close()

    End Sub


    Private Sub Search_btn_Click(sender As Object, e As EventArgs) Handles Search_btn.Click

        Me.Table1TableAdapter.search(Me.Students3DataSet.Table1, idtxt.Text)

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Me.Table1TableAdapter.Fill(Me.Students3DataSet.Table1)

    End Sub

End Class



 

How to add new column IIF in subform with change colors cells based on its value in MS Access forms

Learn how to add a new column with IIF function in a subform and change cell colors based on values in MS Access forms. Improve your form design skills with this tutorial!Videos Access
Subscribe to Youtube
 
https://www.youtube.com/@programmingcode2025/?sub_confirmation=1


Code copy table from one database to another database in MYSQL Workbench

 In this video, We will learn copy table from one database to another database in MYSQL Workbench

Subscribe to my channel to find everyday new information in programming and computer Science
"Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!"
https://www.youtube.com/@programmingcode2025/?sub_confirmation=1
#mysql_tutorial
#mysql
#Wokbench
#mysql_workbench



Full course in 3 minutes connect command line with mysql Workbench

 Full course in 3 minutes connect command line with mysql Workbench

Subscribe to my channel to find everyday new information in programming and computer Science "Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!" https://www.youtube.com/@programmingcode2025/?sub_confirmation=1 #mysql_tutorial #mysql #Wokbench #mysql_workbench


How to fill Combo box by field list in table in forms MS Access database without vba

 How to fill Combo box by field list in table in forms MS Access database without vba



"Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!" https://www.youtube.com/@programmingcode2025/?sub_confirmation=1 #access #msaccess #vbaaccess #microsoft #microsoftaccess


How to use Microsoft Access - Beginner Tutorial 2025


Learn how to use Microsoft Access with this beginner tutorial. Whether you're new to Access or just need a refresher, this video will guide you through the basics of using this powerful database management tool.

Subscribe to my channel to find everyday new information in programming and Computerr Science Subscribe to @programmingforeverybody
https://www.youtube.com/@programmingforeverybody/?sub_confirmation=1