469,315 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

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 15319
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Martin Hazell | last post: by
3 posts views Thread by Nic | last post: by
2 posts views Thread by rn5a | last post: by
1 post views Thread by savajx1 | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.