473,811 Members | 2,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TextBox (read,edit,writ e)

What I'm trying to do:
Open a text file and display the contents in a text box (I've done this)

Need to be able to edit the file from within the textbox and have it save
back to the source file.(can't figure how to do this)

I was thinking on the Open for Output or Append, but I can't get it to
accept a variable(TextBo xText) to open(since it's not a file) , what would
be the simplest way to accomplish this task?
Jul 17 '05 #1
4 15575
"Option^Explici t" <te********@sha w.ca> wrote in message
news:7H******** *************** @news3.calgary. shaw.ca
What I'm trying to do:
Open a text file and display the contents in a text box (I've done
this)

Need to be able to edit the file from within the textbox and have it
save back to the source file.(can't figure how to do this)

I was thinking on the Open for Output or Append, but I can't get it to
accept a variable(TextBo xText) to open(since it's not a file) , what
would be the simplest way to accomplish this task?


how did you get the filename to open in order to put the contents in the
textbox?
you'll need to save that filename so that you can rewrite it
ff=freefile
open filename for output as #ff
put #ff,,text1.text
close #ff
Jul 17 '05 #2
I used this to put text in the box:

FileNum = FreeFile
Open WinDir + "\System32\Driv ers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileN um), FileNum)
H = TxtView.Text
Close FileNum

Now all the text is in the textbox as well as in the "H" variable which I
need to pass somewhere to edit it and resave it to the source file again??
but you cant open H as a file, and I haven't found a way , for when I add or
delete sections from the textbox, to re-evaluate the H to reflect the
changes I made.
I'm thinking I could use
Write #FileNum, H
to write back to the source file once I made changes within the textbox.
My problem is to update the H variable once changes are made within the
textbox

"Bob Butler" <ti*******@nosp am.com> wrote in message
news:SMoOa.1471 41$Dr3.55188@fe d1read02...
"Option^Explici t" <te********@sha w.ca> wrote in message
news:7H******** *************** @news3.calgary. shaw.ca
What I'm trying to do:
Open a text file and display the contents in a text box (I've done
this)

Need to be able to edit the file from within the textbox and have it
save back to the source file.(can't figure how to do this)

I was thinking on the Open for Output or Append, but I can't get it to
accept a variable(TextBo xText) to open(since it's not a file) , what
would be the simplest way to accomplish this task?


how did you get the filename to open in order to put the contents in the
textbox?
you'll need to save that filename so that you can rewrite it
ff=freefile
open filename for output as #ff
put #ff,,text1.text
close #ff

Jul 17 '05 #3
"Option^Explici t" <te********@sha w.ca> wrote in message
news:Kz******** *************** @news1.calgary. shaw.ca
I used this to put text in the box:

FileNum = FreeFile
Open WinDir + "\System32\Driv ers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileN um), FileNum)
H = TxtView.Text
Close FileNum

Now all the text is in the textbox as well as in the "H" variable
which I need to pass somewhere to edit it and resave it to the source
file again?? but you cant open H as a file, and I haven't found a way
, for when I add or delete sections from the textbox, to re-evaluate
the H to reflect the changes I made.
I'm thinking I could use
Write #FileNum, H
Why not use:
FileNum = FreeFile
Open WinDir + "\System32\Driv ers\etc\Hosts" For Output As #FileNum
Print #FileNum,txtVie w.Text;
Clsoe #FileNum

BTW: Write puts quotes around text strings, print will not. Also the
trailing ; prevents Print from appending an extra CR/LF delimiter
to write back to the source file once I made changes within the
textbox. My problem is to update the H variable once changes are made
within the textbox


I don't understand why you need H at all but:

Private Sub Text1_Change()
H=Text1.Text
End Sub

or just
H=Text1.Text
right before you write it out

Jul 17 '05 #4
Thanks Bob, I actually found the "Private Sub TxtView_Change( )" last night,
but I had no idea where those stupid quotes were coming from...but now I
do:)

"Bob Butler" <ti*******@nosp am.com> wrote in message
news:AmFOa.9426 5$Pc5.12018@fed 1read01...
"Option^Explici t" <te********@sha w.ca> wrote in message
news:Kz******** *************** @news1.calgary. shaw.ca
I used this to put text in the box:

FileNum = FreeFile
Open WinDir + "\System32\Driv ers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileN um), FileNum)
H = TxtView.Text
Close FileNum

Now all the text is in the textbox as well as in the "H" variable
which I need to pass somewhere to edit it and resave it to the source
file again?? but you cant open H as a file, and I haven't found a way
, for when I add or delete sections from the textbox, to re-evaluate
the H to reflect the changes I made.
I'm thinking I could use
Write #FileNum, H


Why not use:
FileNum = FreeFile
Open WinDir + "\System32\Driv ers\etc\Hosts" For Output As #FileNum
Print #FileNum,txtVie w.Text;
Clsoe #FileNum

BTW: Write puts quotes around text strings, print will not. Also the
trailing ; prevents Print from appending an extra CR/LF delimiter
to write back to the source file once I made changes within the
textbox. My problem is to update the H variable once changes are made
within the textbox


I don't understand why you need H at all but:

Private Sub Text1_Change()
H=Text1.Text
End Sub

or just
H=Text1.Text
right before you write it out

Jul 17 '05 #5

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

Similar topics

6
12752
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
2
2540
by: Martin Hazell | last post by:
For various reasons, I have had to produce a quick (!) page to edit one column of data in a database with ASP.net. With this being my first foray into ASP.net, I apoligise for any basic erros I have made. The main problem is when setting up an ASP.net datagrid, which I can edit the single value of a specific column. I have wired up the update and edit methods to change the current edit row. I worked through the example in the MSDN help to...
3
2210
by: Nic | last post by:
Hey, I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>. Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but here it don't exists. How can I resolve this problem? Tkx; Nic
10
9144
by: mg | last post by:
I want to enter characters in a TextBox in a WebForm, press a Button in the WebForm, and read the characters that were typed into the TextBox from within the Button_Click event handler. The main point here is that I want to read the value typed into the TextBox without hitting the Enter key or setting focus on another control ...
0
1039
by: Greg | last post by:
I am able to read an html file and display the text in a textbox, no problem: Dim sr As New StreamReader(Server.MapPath("myfile.htm") Dim str as string = sr.ReadToEnd txtBox.Text = str Once in the textbox, the user can edit this standard template before saving it to a database.
1
12236
by: cyningeston | last post by:
OS: WinXP Pro, VB/ASP/ADO.NET I'm building a web-based supplier management application. For each supplier we are required by the FDA to track certain documents. I've managed to pull them from Access into a Gridview (Gridview1), in which I have AutoGenerateEditButton set to True. What I want is this: when a user clicks "Edit" on a line and it goes to edit mode, I want to grab the supplier's category (4th column of the grid, named...
2
2126
by: rn5a | last post by:
A DataGrid displays 8 columns - ProductID, ProductName, Description, Price, Quantity, Sub-Total, Edit & Delete. *Edit* is a EditCommandColumn, *Delete* is a ButtonColumn & *Quantity* is a BoundColumn. If the *Edit* link is clicked, the *Quantity* column changes to the editable mode with a TextBox & the text under the *Edit* column of the corresponding row gets replaced by 2 hyperlinks - Update & Cancel. In order to ensure that the width...
1
15049
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have to add controls dynamically as I am trying to write a reusable , general , spreadsheet like display control that can take advantage of the built- in update and delete features of the SqlDataSource/Gridview controls. This user control can get its...
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10397
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10410
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3878
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.