System.NullReferenceException help!!

  • Thread starter Thread starter k7s41gx
  • Start date Start date
K

k7s41gx

Guest
Hey all,


I am having an exception thrown which tells me basically it is returning a nothing value. Which is fine, but I am trying to tell it to perform x on nothing. Code below. I know this is returning nothing because the cell is blank with nothing in it, so I want the program to create a space in the datagrid / list.

For i As Integer = 2 To counta
If xlWorkSheet2.Cells(i, 21).value.ToString = Form3.Label1.Text Then
For y As Integer = 1 To 33
If xlWorkSheet2.Cells(i, y).value.ToString Is Nothing Then
temp1.Add(" ")
TextBox2.Text = "Skipping Cell"
Else
temp2 = xlWorkSheet2.Cells(i, y).value.ToString
temp1.Add(temp2)
TextBox2.Text = xlWorkSheet2.Cells(i, y).value.ToString
End If
Next
Form3.DataGridView1.Rows.Add(temp1)
ProgressBar1.Value = ProgressBar1.Value + 1
Else
ProgressBar1.Value = ProgressBar1.Value + 1
End If
Next

Continue reading...
 
Back
Top