cant use variable counter inside loop <p>I have database connected to my app in vb.net</p> <p>if i want to get the value from any row or column i use this code and it's work fine</p> <pre><code>DataGridView1.Rows(1).Cells(1).Value.ToString </code></pre> <p>my problem is i have table contain 14 row and i want to make loop to check the first cell in every row if it's contain specific value to do other task</p> <p>if i use the variable i in counter i got an error </p> <p>in this code</p> <pre><code> Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click Dim see As String For i As Int32 = 0 To 14 see = DataGridView1.Rows(i).Cells(1).Value.ToString If see = "FLOWRATE" Then TextBox11.Text = TextBox11.Text &amp; see &amp; " " End If Next End Sub </code></pre> <p>when i press the button i got this error</p> <pre><code>An unhandled exception of type 'System.NullReferenceException' occurred in project1.exe Additional information: Object reference not set to an instance of an object. </code></pre>