Hello, i'm having trouble opening a text file to process and order the data in it. When i try to read the first line of characters an error message occurs saying: 'Variable words1 is used before it has been assigned a value.' I dont understand what i am doing wrong when opening the file. Also, I am sorry if this is a rather basic question.
Public Class frmAssign6
Dim sr As IO.StreamReader = IO.File.OpenText("words.txt")
Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
Dim words1 As String 'Line 1?
While Not (sr.EndOfStream)
words1 = sr.ReadLine
End While
lstResults.Items.Add(words1)
End Sub
End Class