I'm having issues with my code and the objective is that I want it to send to a DataGridView a "product" when you click on the image of said "product" but it gives me this error:
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
s1 = s1 + 1
If s1 = 0 Then
s1 = 1
Compras.DataGridView3.Rows.Add("1", " Paracetamol")
ElseIf s1 = 1 Then
s1 = 0
For Each fila As DataGridViewRow In Compras.DataGridView3.Rows
If fila.Cells(1).Value = " Paracetamol" Then
Compras.DataGridView3.Rows.Remove(fila)
End If
Next
End If
Compras - Is the form where its located fila - means line in Spanish (need this because my teacher only speaks Spanish) How do I fix this or is there a way to create a checkout easier? Thanks for the help!
I tried maybe deleting the "filas" part and just putting "compras" but nope also read the article that Microsoft has but not much of a help (sorry for having a smooth brain)
The error pop up is
System.NullReferenceException: 'Object reference not set to an instance of an object.' FarRanita.Compras.DataGridView3.get returned Nothing.