Load text file to textBox

G

Guest

Hi EveryBody:

How can I load data from text file to textBox ?

any help will be appreciated

regard's

Husam
 
C

Crouchie1998

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
 
S

Stephany Young

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top