473,396 Members | 1,726 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,396 software developers and data experts.

TextBox (read,edit,write)

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(TextBoxText) to open(since it's not a file) , what would
be the simplest way to accomplish this task?
Jul 17 '05 #1
4 15542
"Option^Explicit" <te********@shaw.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(TextBoxText) 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\Drivers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileNum), 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*******@nospam.com> wrote in message
news:SMoOa.147141$Dr3.55188@fed1read02...
"Option^Explicit" <te********@shaw.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(TextBoxText) 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^Explicit" <te********@shaw.ca> wrote in message
news:Kz***********************@news1.calgary.shaw. ca
I used this to put text in the box:

FileNum = FreeFile
Open WinDir + "\System32\Drivers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileNum), 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\Drivers\etc\Hosts" For Output As #FileNum
Print #FileNum,txtView.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*******@nospam.com> wrote in message
news:AmFOa.94265$Pc5.12018@fed1read01...
"Option^Explicit" <te********@shaw.ca> wrote in message
news:Kz***********************@news1.calgary.shaw. ca
I used this to put text in the box:

FileNum = FreeFile
Open WinDir + "\System32\Drivers\etc\Hosts" For Input As FileNum
TxtView.Text = Input(LOF(FileNum), 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\Drivers\etc\Hosts" For Output As #FileNum
Print #FileNum,txtView.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
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
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...
3
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...
10
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...
0
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...
1
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...
2
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...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.