Null Reference Exception Unhandled

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 2
Reputation: robee31 is an unknown quantity at this point 
Solved Threads: 0
robee31 robee31 is offline Offline
Newbie Poster

Null Reference Exception Unhandled

 
0
  #1
Nov 9th, 2008
I am getting the above error from the following code and I a not understanding why.

  1. fileWriter.WriteLine( _
  2. record.strFirstName & "," & record.strLastName & "," & _
  3. record.strStudentId & "," & record.strCourseName & "," & _
  4. record.strGrade)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 66
Reputation: Renukavani is an unknown quantity at this point 
Solved Threads: 6
Renukavani Renukavani is offline Offline
Junior Poster in Training

Re: Null Reference Exception Unhandled

 
0
  #2
Nov 11th, 2008
hi
send ur ful code then v can help u
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 2
Reputation: robee31 is an unknown quantity at this point 
Solved Threads: 0
robee31 robee31 is offline Offline
Newbie Poster

Re: Null Reference Exception Unhandled

 
0
  #3
Nov 11th, 2008
Here is the entire code, I figured out why I am getting the above error yet I am not able to get the code to write to the file that is created.

  1. Private Sub btnEnter_Click(ByVal sender As System.Object, _
  2. ByVal e As System.EventArgs) _
  3. Handles btnEnter.Click
  4.  
  5. Dim values As String() = GetTextBoxValues()
  6.  
  7. Dim record As New GradeBookDataCollector()
  8.  
  9. Me.SetTextBoxValues(GetTextBoxValues)
  10. If values(TextBoxIndices.txtFirstName) <> "" Then
  11.  
  12. Try
  13. Dim strFirstName As String = _
  14. values(TextBoxIndices.txtFirstName)
  15.  
  16. If strFirstName <> "" Then
  17. record.strFirstName = values(TextBoxIndices.txtFirstName)
  18. record.strLastName = values(TextBoxIndices.txtLastName)
  19. record.strCourseName = values(ComboBoxIndices.cboCourseName)
  20. record.strStudentId = values(TextBoxIndices.txtStudentId)
  21. record.strGrade = values(ComboBoxIndices.cboGrade)
  22.  
  23. fileWriter.WriteLine( _
  24. record.strFirstName.ToString & "," & record.strLastName.ToString & "," & _
  25. record.strStudentId.ToString & "," & record.strCourseName.ToString & "," & _
  26. record.strGrade.ToString)
  27.  
  28.  
  29. Else
  30. MessageBox.Show("Invalid First Name", "Error", _
  31. MessageBoxButtons.OK, MessageBoxIcon.Error)
  32. End If
  33.  
  34. Catch ex As IOException
  35. MessageBox.Show("Error Writing to File", "Error", _
  36. MessageBoxButtons.OK, MessageBoxIcon.Error)
  37.  
  38. Catch ex As FormatException
  39. MessageBox.Show("Invalid Format", "Error", _
  40. MessageBoxButtons.OK, MessageBoxIcon.Error)
  41.  
  42. End Try
  43. End If
  44.  
  45. Me.SetTextBoxValues(GetTextBoxValues)
  46. Me.ClearFormDataEntryBoxes()
  47.  
  48. End Sub
  49. (Rate)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 66
Reputation: Renukavani is an unknown quantity at this point 
Solved Threads: 6
Renukavani Renukavani is offline Offline
Junior Poster in Training

Re: Null Reference Exception Unhandled

 
0
  #4
Nov 12th, 2008
hi
first set the breakpoint to starting line of function and then u can no eaasily somwhere its not set the value that s y this above error and use try-catch block its useful to findout that error
Last edited by Renukavani; Nov 12th, 2008 at 12:33 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 2430 | Replies: 3
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC