0

when i tried to get a value from other form this message faced me. any one can help to solve it please

this is my code ..

    Private Sub b_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_ok.Click
        If b.Count = 0 OrElse t_search.Text = "" Then
            MessageBox.Show("please choose the customer", "warning ", MessageBoxButtons.OK, MessageBoxIcon.Error)
            b.RemoveFilter()
            t_search.Text = ""
            t_search.Focus()
            Exit Sub
        End If

        If frm.Name = "sales" Then
            t_search.Text = datagv.CurrentCell.Value
            sales.t_custom_id.Text = datagv.CurrentRow.Cells(0).Value
            sales.t_custom_name.Text = datagv.CurrentRow.Cells(1).Value

        End If
        Me.Close()

    End Sub


  • have you tried to look into the error with some try catch and/or putting some breakpoints into the code? https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/try-catch-finally-statement | https://learn.microsoft.com/en-us/visualstudio/debugger/using-breakpoints?view=vs-2019 a null reference exception occurs whenyou try to use a variable that you haven't declared before – Francesco Jun 22 '20 at 12:32
  • As @Francesco says, a little debugging wouldn't hurt. You haven't even told us on which line of your posted code you getting the exception – Hursey Jun 22 '20 at 20:41

0 Answers0