Kwame Ima Debrah Kwame Ima Debrah - 6 months ago 13
Vb.net Question

How to read lines in a text file daily

I am an IT student from Ghana and I am writing a program in visual basic. The program is suppose to read different lines from a text file and display them line by line into a textbox everyday. I have search very hard on the internet but have had no results yet. I would be much grateful if anyone can help me here. Thank you in advance

Answer

Here is something that i have quickly written up for you that should do that trick.
There are many ways to accomplish your task at hand.
Here is one way, You will need to change some parts for it, however you should be able to understand it :)

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim USER = Environment.UserName
    Dim Location As String = "C:\Users\" & USER & "\Desktop\textfile.txt"
    Dim File = System.IO.File.ReadAllLines(Location)
    Dim myFile() As String = File

    For Each item As String In myFile
        TextBox1.Text += item & vbNewLine
    Next
    ''ADD YOUR NEXT PART OF THE CODE HERE
End Sub

End Class

If you have any problems, let me know and i will do my best to help you out :)
UPDATE: I have added the items to its own array before being sent to the textbox just to be safe.