title: VB.NET Object reference not set to an instance of an object
body: <p>I have been using the following code to changes the cell value color in a datagridview without any problem until I transfer it to a new project, and connecting the project to a different server.  and it is now throwing a "Object reference not set to an instance of an object" error..  What am I missing??</p>
  
  <p>It work from GridViewTextBoxColumn1, until it move down to GridViewTextBoxColumn2 and the debugger start throwing error like.  Value cannot be converted to type Datetime, then Object reference not set etc..  But I check everywhere and everything seems to be in place, and don't understand how it ended up with a datetime..   </p>
  
  <pre><code> Private Sub TableGrid_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles TableGrid.CellFormatting
  
      For i As Integer = Nothing To Me.TableGrid.Rows.Count - 1
          If Me.TableGrid.Rows(i).Cells("GridViewTextBoxColumn1").Value &lt;= 0 Then
              Me.TableGrid.Rows(i).Cells("GridViewTextBoxColumn1").Style.ForeColor = Color.Red
          End If
      Next
      For j As Integer = Nothing To Me.TableGrid.Rows.Count - 1
          If Me.TableGrid.Rows(j).Cells("GridViewTextBoxColumn2").Value.ToString = "S" Then
              Me.TableGrid.Rows(j).Cells("GridViewTextBoxColumn2").Style.ForeColor = Color.Blue
          End If
      Next
  
      For k As Integer = Nothing To Me.TableGrid.Rows.Count - 1
          If Me.TableGrid.Rows(k).Cells("GridViewTextBoxColumn3").Value.ToString = "Z" Then
              Me.TableGrid.Rows(k).Cells("GridViewTextBoxColumn3").Style.ForeColor = Color.Blue
          End If
      Next
  
  End Sub
  </code></pre>