I'm making a simple program which reads and writes .txt files. I've got the program to write to and save a .txt file however I'm having some trouble reading from .txt files. Here's what I've got so far:
Using openTxt As New OpenFileDialog()
If openTxt.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim displayForm As New Form
Dim textReader As New System.IO.StreamReader(openTxt.FileName)
displayForm.ListBox1.Text = textReader.ReadToEnd
textReader.Close()
displayForm.Show()
Else
MessageBox.Show("Not a text file")
End If
End Using
What I would like to happen is when the text has been read it populates in a list box which is present inside another form (displayForm). I've tried getting the text to display in a listbox on the same form to see if that might have changed anything but it still remains blank. I can confirm that I've only ever tested it with .txt files as I've put no error checking in at this stage. Many thanks for any help!