I am in the middle of developing an application that will load lines of text from a txt file to specific textboxes. For example textbox1 would read from line one on the text file.
I have this codes that will read a text file and apply it to a multiline box, however I'd like to be able to read a single line and apply it to a single textbox.
Any ideas on what I can do to either update this code, or is there another code that I could utilize?
Also, this can be saved for later, but I'd like to also be able to save those textboxes to the textfile.
I have this codes that will read a text file and apply it to a multiline box, however I'd like to be able to read a single line and apply it to a single textbox.
Code:
Public Class Form1
Private myCoolFile As String = "C:\passwords.txt" '// your file.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myCoolFile) Then '// check if File Exists.
TextBox1.Text = IO.File.ReadAllText(myCoolFile) '~~~ Read all text from file to a "MultiLine" Textbox
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
IO.File.WriteAllText(myCoolFile, TextBox1.Text) '~~~ Write back the text to the file
MessageBox.Show("Saved !")
End Sub
End Class
Also, this can be saved for later, but I'd like to also be able to save those textboxes to the textfile.