Public Class Form3
    Inherits Windows.Forms.Form
    Public F1 As Form1
    Dim S1 As String = F1.TextBox2.Text
    Public Sub New()
        InitializeComponent()
        BindGrid()
    End Sub
    Private Sub bindgrid()
        Dim con As New SqlConnection
        '/ Dim cmd As New SqlCommand
        con.ConnectionString = "server=hcl-pc\SQLEXPRESS;Initial Catalog=UBGB_HRMS;Integrated Security=True"
        ''/Dim S2 As String
        '/ S1 = F1.TextBox1.Text
        '/ S2 = F1.TextBox2.Text
        ''/If String.IsNullOrEmpty(S1) Then
        '/Return
        '/ End If
        Using cmd As New SqlCommand("SELECT *FROM emp_personal_details where emp_adhaar=s1", con)
            cmd.CommandType = CommandType.Text
            Using sda As New SqlDataAdapter(cmd)
                Using dt As New DataTable()
                    sda.Fill(dt)
                    DataGridView1.DataSource = dt
                End Using
            End Using
        End Using
    End Sub
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    End Sub
End Class
I am using multiple windows form and assigning the value of form1 in form3. Form1 is required for the variable s1. While debugging, I am getting the error:
null reference was unhanded
 
     
     
    