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? | | | | re: TextBox (read,edit,write)
"Option^Explicit" <techsmail%@shaw.ca> wrote in message
news:7HmOa.381075$3C2.10376797@news3.calgary.shaw. ca[color=blue]
> 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?[/color]
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 | | | | re: TextBox (read,edit,write)
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" <tiredofit@nospam.com> wrote in message
news:SMoOa.147141$Dr3.55188@fed1read02...[color=blue]
> "Option^Explicit" <techsmail%@shaw.ca> wrote in message
> news:7HmOa.381075$3C2.10376797@news3.calgary.shaw. ca[color=green]
> > 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?[/color]
>
> 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
>
>[/color] | | | | re: TextBox (read,edit,write)
"Option^Explicit" <techsmail%@shaw.ca> wrote in message
news:KzqOa.410642$Vi5.10588801@news1.calgary.shaw. ca[color=blue]
> 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[/color]
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
[color=blue]
> 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[/color]
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 | | | | re: TextBox (read,edit,write)
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" <tiredofit@nospam.com> wrote in message
news:AmFOa.94265$Pc5.12018@fed1read01...[color=blue]
> "Option^Explicit" <techsmail%@shaw.ca> wrote in message
> news:KzqOa.410642$Vi5.10588801@news1.calgary.shaw. ca[color=green]
> > 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[/color]
>
> 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
>[color=green]
> > 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[/color]
>
> 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
>[/color] |  | Similar Visual Basic 4 / 5 / 6 bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|