Groups | Blog | Home
all groups > vb.net > april 2005 >

vb.net : Load text file to textBox



Husam
4/19/2005 11:04:02 PM
Hi EveryBody:

How can I load data from text file to textBox ?

any help will be appreciated

regard's

Cor Ligthert
4/20/2005 12:00:00 AM
Husam,

See this link there are a lot more methods and other classes to use on that
Streamreader
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiostreamreaderclasstopic.asp

I hope this helps,

Cor

Crouchie1998
4/20/2005 12:00:00 AM
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

Stephany Young
4/20/2005 12:00:00 AM
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.


[quoted text, click to view]

Herfried K. Wagner [MVP]
4/20/2005 11:01:00 AM
"Husam" <Husam@discussions.microsoft.com> schrieb:
[quoted text, click to view]

Please read replies given to your question some days ago instead of asking
the same questions again and again:

<URL:http://www.google.de/groups?selm=uKUbJErQFHA.1392%40TK2MSFTNGP10.phx.gbl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
AddThis Social Bookmark Button