473,387 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Writing to textbox from a file

Hi,
I have a text file with some text in.
I have a textbox called textbox1 for example.
what do I do so when I click on a button (button1) it opens the text file in
the textbox so I can edit it.
also how do I save it

I am newbie as you can tell. I have tried and looked on the msdn but I am
stuggling.

Cheers Russ
Nov 21 '05 #1
2 1066
"Russell" <Ru*****@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
Hi,
I have a text file with some text in.
I have a textbox called textbox1 for example.
what do I do so when I click on a button (button1) it opens the text file
in
the textbox so I can edit it.
also how do I save it

I am newbie as you can tell. I have tried and looked on the msdn but I am
stuggling.

Cheers Russ


Dim stream As IO.StreamWriter = New IO.StreamWriter(pathtotextfile)
stream.Write(txtTextBox1.Text)
stream.Close()
Hope this helps ;)

Mythran
Nov 21 '05 #2
Russel,

Have a look at these pages where are links inside. There are samples and one
of those will probably include your question or almost your question.

What you have to do is
Create a windowsform project
Drag from your toolbox on the left a textbox to the form
Drag a button on your form
Click on that button
Insert this code inside the sub you see.

\\\\
Try
Dim sr As New StreamReader("Your Path of the file")
textBox1. = sr.ReadToEnd()
sr.Close()
Catch Ex As Exception
' Let the user know what went wrong.
MessageBox.Show("The file could not be read:" & Ex.Message)
End Try
////

Do debug start

A link
http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JP | last post by:
I'm sure this is a simple question and I'm overlooking the obvious. But, I have two seperate classes (in seperate files) under the same namespace. I am calling a method in one class that contains...
4
by: JP | last post by:
Okay - I have incorporated some of the advise I got on the first post and have gone ahead and setup a simple test project to demonstrate the trouble I am having. Any help is GREATLY appreciated: ...
3
by: CsharpNewcommer | last post by:
Hi Can someone tell me how to write the data from a TextBox (txt) or Label (lbl) to a text file to be printed. I have read the info from msdn.microsoft.com/library on "Writing Text to a File",...
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
3
by: poldoj | last post by:
First I would thank you all for the replies at my previous post. Say sorry for my poor english also. I have found where my problem came from. I am writing a string to a text box and write the...
16
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
3
by: manmit.walia | last post by:
Hello All, I am stuck on a problem with updating an XML file. Here is what my final solution suppose to do. I have a web form which displays all users that are authorized for recieving a...
5
by: slinky | last post by:
I'm struggling with what should be a very basic .aspx/XML issue. I have an XML file. I have a textbox for a user to enter data and a button to submit the data. I don't wont the user to see the...
0
by: mcc99 | last post by:
Amazing, I surfed around to find a simple utility that could list files recursively from a given top folder down through it, writing out the path and filename in simple \path\file_name form, without...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.