TextBox (read,edit,write)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Option^Explicit

    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(TextBo xText) to open(since it's not a file) , what would
    be the simplest way to accomplish this task?


  • Bob Butler

    #2
    Re: TextBox (read,edit,writ e)

    "Option^Explici t" <techsmail%@sha w.ca> wrote in message
    news:7HmOa.3810 75$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(TextBo xText) 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


    Comment

    • Option^Explicit

      #3
      Re: TextBox (read,edit,writ e)

      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" <tiredofit@nosp am.com> wrote in message
      news:SMoOa.1471 41$Dr3.55188@fe d1read02...[color=blue]
      > "Option^Explici t" <techsmail%@sha w.ca> wrote in message
      > news:7HmOa.3810 75$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(TextBo xText) 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]


      Comment

      • Bob Butler

        #4
        Re: TextBox (read,edit,writ e)

        "Option^Explici t" <techsmail%@sha w.ca> wrote in message
        news:KzqOa.4106 42$Vi5.10588801 @news1.calgary. shaw.ca[color=blue]
        > 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[/color]

        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
        [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

        Comment

        • Option^Explicit

          #5
          Re: TextBox (read,edit,writ e)

          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@nosp am.com> wrote in message
          news:AmFOa.9426 5$Pc5.12018@fed 1read01...[color=blue]
          > "Option^Explici t" <techsmail%@sha w.ca> wrote in message
          > news:KzqOa.4106 42$Vi5.10588801 @news1.calgary. shaw.ca[color=green]
          > > 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[/color]
          >
          > 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
          >[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]


          Comment

          Working...