I am trying to read a file in with the following code and I am getting a system.nullreferenceexception error. The error is “object reference not set to an instance of an object”. This is my code below and I can’t figure out what I am doing wrong. I have used this before and know it works….there is no reason for this not too. Help, please
Private strPhraseFile As Strin
Private intPhrases As Intege
Private objReader As StreamReade
Private Sub mnuGamePhrase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGamePhrase.Clic
Dim intX As Intege
Dim strDummy As Strin
Me.dlgOpen.Filter = "Text files {*.txt}| *.txt|All files {*.*}|*.*
Me.dlgOpen.InitialDirectory = Application.StartupPat
Me.dlgOpen.FilterIndex =
Me.dlgOpen.Title = "Open Phrases file
If Me.dlgOpen.ShowDialog = DialogResult.OK Then 'display dialog and accept user inpu
strPhraseFile = Me.dlgOpen.FileNam
Dim objReader As StreamReader = New StreamReader(strPhraseFile
End I
intPhrases =
strDummy = "Dummy Value
Do Until strDummy = Nothing 'Count the record
strDummy = objReader.ReadLine(
If strDummy = Nothing The
Els
intPhrases = intPhrases +
End I
Loo
objReader.Close(
objReader = Nothin
End Su