473,800 Members | 2,648 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 15574
"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
12750
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
2531
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
2209
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
9690
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
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
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.