Hi, I am trying to store individual lines of a .txt file in a ComboBox, here is my code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim FILE_NAME As String = "history.txt" If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Dim Line As String = "" Do While objReader.Peek() <> -1 Line = Line & objReader.ReadLine() & vbNewLine ComboBox1.Items.Add(Line) Loop Else 'MsgBox("File Does Not Exist") End If End Sub
Whenever I run this, I get the TargetInvocationException error. I do not know how to fix this, after many tries. Anyone know how to fix this?