473,385 Members | 1,562 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,385 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 15540
"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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.