Load text file to textBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi EveryBody:

How can I load data from text file to textBox ?

any help will be appreciated

regard's

Husam
 
Dim strFile As String = "C:\MyFileHere.txt"
Dim sr As New IO.StreamReader(strFile)

TextBox1.Text = sr.ReadToEnd()

sr.Close()

Crouchie1998
BA (HONS) MCP MCSE
 
A simple is to open the file and assign the entire content to the
TextBox.Text property:

Dim _sr As StreamReader = File.OpenText(<file_name>)

<TextBox>.Text = _sr.ReadToEnd()

_sr.Close()

making sure of course that you have set the TextBox.Multiline and other
relevant properties correctly.

If you happened to be feeling brave you could create your own TextBox class
derived from TextrBox and add a method to load the textbox from the
specified file.
 
Back
Top