How do I pass values from a button to another button sub

Here is my problem, I don’t know how to pass these values,
I want to get the row value from here:

Public Sub DataGridView2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
    If e.RowIndex >= 0 Then
        Dim row As DataGridViewRow
        row = Me.DataGridView2.Rows(e.RowIndex)

        Label12.Text = row.Cells("title").Value.ToString
        Label13.Text = row.Cells("borrower").Value.ToString
        Dim b As Date = row.Cells("date").Value
        Dim a = Format(b, "yyyy-MM-dd")
        Label15.Text = a.ToString
        Dim c As Date = Me.DateTimePicker2.Value
        Dim daysborrowed As Integer = c.Subtract(a).Days
        Label16.Text = daysborrowed.ToString

    End If
End Sub

then pass it here:

Public Sub Button6_Click(sender As Object, e As EventArgs, o As DataGridViewCellEventArgs) Handles Button6.Click
    Using mysqlconn = libconn()
        Dim reader As MySqlDataReader

            query = "Delete From borrowed where bookid = '" & Me.DataGridView1.CurrentRow.Cells(0).Value & "' "
            Dim query1 As String = "INSERT INTO `books`(`title`, `author`, `published`, `ISBN`) VALUES ('" & row.Cells("title").Value.ToString & "','" & row.Cells("author").Value.ToString & "','" & row.Cells("published").Value.ToString & "','" & row.Cells("ISBN").Value.ToString & "')"
            Dim command As New MySqlCommand(query, mysqlconn)
            reader = command.ExecuteReader
            MessageBox.Show("Book deleted")
        Catch ex As Exception
        End Try
    End Using
End Sub

I am a newbie programmer btw.

Source: sql

Leave a Reply

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