Results 1 to 3 of 3

Thread: [RESOLVED] Saving textbox text to a file WITHOUT user clicking.

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Resolved [RESOLVED] Saving textbox text to a file WITHOUT user clicking.

    Hello,

    Is there anyway for me to get my program to just save my textbox text to a txt file without the user having to enter a filename and click on save?

    Example.
    Right now I am using this code.

    But as you can see it requires the user to enter a file name and click save.

    My form has the commponent Microsoft Common Dialog Control (Named cdl)
    a textbox (Named txtTest.txt)

    and a command button

    VB Code:
    1. Private Sub Command1_Click()
    2.     cdl.Filter = "App File|*.smd"
    3.     cdl.InitDir = "C:\Test.Txt"
    4.     cdl.ShowSave
    5.     If Len(cdl.FileName) = 0 Then Exit Sub
    6. Close
    7.     Open cdl.FileName For Binary As #1
    8.     Put #1, , txtTest.Text
    9.     Close #1
    10. End Sub

    Is there any way to change this so that it is auto save when the user clicks the command button. Also I would want the program to save the text to the txt file without deleteing what is already in the file. So it would just add it on in a new line.

    Thank you all!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Saving textbox text to a file WITHOUT user clicking.

    VB Code:
    1. Open "C:\some filename that you cant change since you want to remove the common dialog.smd" For Append As #1
    2.     Print #1,txtTest.Text
    3.     Close #1


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: Saving textbox text to a file WITHOUT user clicking.

    Thanks man! That did it perfect!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

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