Hi All,
I am sure having problems with reading from a sequential file. I created a .txt file and placed it several places within the vb.net file folder for the program that I am writing. The problem is that when I try and run the program I get the message that file is not found. I cannot figure out what to do or where to place the file. I have to e-mail the whole folder to my instructor as well.
Here is the code that I have:
'declare object reader, string variables and array count
Dim objReader As IO.StreamReader
Dim _strInterestRates(3) As String
Dim intArrayCount As Integer = 0
If System.IO.File.Exists("\interestRates.txt") = True Then
objReader = System.IO.File.OpenText("\interestRates.txt")
Do While objReader.Peek <> -1 '-1 is the null value
_strInterestRates(intArrayCount) = objReader.ReadLine()
intArrayCount += 1 'add one to the array counter
Loop
objReader.Close()
Else : MessageBox.Show("The external interest rates file does not exist", "Mortgage Calculator", MessageBoxButtons.OK)
End If
I have 3 values in the .txt file and read them to 3 different buttons depending which one is checked.
Any help would really be appreciated.
Thanks,
Ken