Hi all
I am trying to get my program to read a text file one line at a time and then return the first line to text box 1, the second line to text box 2 and so on. It is a recipe storing program with a list of ingredients. I can write to the text file no problem but reading it is proving difficult. I ahve attached my code so far:
Public Class Form3
Private Sub cmdView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdView.Click
Dim FILE_NAME As String = "C:\Users\wm\test2.txt"
Dim TextLine As String
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
TextBox1.Text = TextLine
Else
MsgBox("File does not exist")
End If
End Sub
End Class