Results 1 to 5 of 5

Thread: Saving to text doc

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Question

    How would I be able to save whats in a textbox, to a text document?

    eg: You click the save button, and a message pops up asking you what you want to name it, and then it saves in programs directory?

    I would really appreciate the help thanks!

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    1. put a cmdialog control on your form, name it cmd
    2. make a commandbutton and a textbox
    3. put this code in your form
    Code:
    Private Sub Command1_Click()
    dim ff as integer
        On Error Resume Next
        cmd.ShowSave
        If Err Then Exit Sub
        ff = FreeFile
        Open cmd.filename For Binary As #ff
            If Err Then Exit Sub
            Put ff, , Text1
        Close ff
    End Sub
    4. pressing the button will now show up a savedialog and save it if you choose a correct name.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    Kedaman, Why would you use Binary and not Output?
    Code:
    Private Sub Command1_Click()
    On Error Resume Next
    commondialog1.ShowSave
    Open commondialog1.filename For Output As #1
    Print #1, Text1
    Close #1
    End Sub


    [Edited by Matthew Gates on 07-03-2000 at 09:41 AM]

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Is there a particular difference in this case?

    Don't leave the cancelerror unhandled Matthew or you will save a file whether you press cancel or not.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    Code:
    If Err Then Exit Sub 'fixed
    Oops. That was just an example anyway Kedaman. I guess there is no difference.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width