VS 2010 Saving textbox1.text to .txt file-VBForums
Results 1 to 15 of 15

Thread: Saving textbox1.text to .txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Saving textbox1.text to .txt file

    Hey

    I basically have a program where people type in their username and password, and then once button1 is pressed the program takes you to a website and logs in for you. The whole point of this is to fast the process.

    What I would like to do is save the textbox1.text and textbox2.text to a text file (stored on the desktop) when the program is closed. Everytime the program is opened again, I would like it to import the information from the .txt file and put it into the textboxes.

    I have tried multiple things but they all are for older versions. Could anyone help out for VS 2010?

    Thanks

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    4,122

    Re: Saving textbox1.text to .txt file

    Why are you using a textfile when you can property bind the control using my.settings.

    http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    I have tried earlier but it just wouldn't work. Is there a code for this that you add in open form and closing form?

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    4,122

    Re: Saving textbox1.text to .txt file

    You have tried.... How does that help me help you. Explain what you done in detail. What is not working.
    Let's be truthful. You have not read the link i posted.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Exclamation Re: Saving textbox1.text to .txt file

    Sorry about that. This is what I have tried earlier:

    Const mfileName As String = "C:\test.txt"
    Dim file As System.IO.StreamWriter file = My.Computer.FileSystem. _ OpenTextFileWriter(mfileName, True) file.WriteLine(TextBox1.Text) file.Close()

    It doesn't give any errors but at the same time, it doesn't seem to do the work.

    I have looked at the link you provided, but I don't know what it's going to do (if I follow all those instructions). What kind of application settings would it save, etc.

    Thanks!

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    4,122

    Re: Saving textbox1.text to .txt file

    What has any of that got to do with my first post?

    I think it is pretty clear what it is going to do "Application settings allow you to store and retrieve property settings and other information for your application dynamically."

    if you bother to read it in full and try you will learn. I don't mind helping you but if you refuse to help your self then it is pointless.

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    Okay, i'll give it a try. Which one should I try though?
    To add application settings in the Project Designer or
    To add application settings in the Properties window

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    4,122

    Re: Saving textbox1.text to .txt file

    The second paragraph states "At design time, you can add application settings either using the Settings pane of the Project Designer, or using the Properties window for a form or control, which allows you to bind a setting directly to a property."

    You want to bind a string to a textbox. so you follow the steps of "To add application settings in the Properties window"

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    I will give it a try and feedback. Will you also be able to help me with:
    http://www.vbforums.com/showthread.php?t=672838

    Thanks much

  10. #10

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    I have tried To add application settings in the Properties window
    followed all the steps though it doesn't do anything
    when I close it and open it again, I have to enter the user and pass again.
    It doesn't remember it
    Help?

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    4,122

    Re: Saving textbox1.text to .txt file

    as i said before. You are not giving me any information. state the steps you have taken. I cant magically say what is wrong with out information from you.

  12. #12
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    4,981

    Re: Saving textbox1.text to .txt file

    Hi Y0MANNN, I think that the reason that you aren't getting much help is because of the manner you are posting. Please don't double post(aka bump), and take in the information that people give you.
    You have tried.... How does that help me help you. Explain what you done in detail. What is not working.
    Let's be truthful. You have not read the link i posted.
    Why should ident keep helping you out if you won't let him help you? Your previous post has no info on what you've tried to do other than "I've followed all the steps, though it doesn't do anything"

    In your thread that you've posted above, you have three post back to back within three hours of the origional post. When you do stuff like that its like wanting to have a vb expert at your side 24/7. You also do the same thing to Shaggy where you don't post an answer to his question
    What are you really wanting to do? Perhaps the problem can be narrowed down to a problem that is solvable.
    As to the question, there is this little bit of info at the very end
    Note that once you have created the setting, you must use the Project Designer to change it.

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    4,997

    Re: Saving textbox1.text to .txt file

    Quote Originally Posted by Y0MANNN View Post
    Sorry about that. This is what I have tried earlier:

    Const mfileName As String = "C:\test.txt"
    Dim file As System.IO.StreamWriter file = My.Computer.FileSystem. _ OpenTextFileWriter(mfileName, True) file.WriteLine(TextBox1.Text) file.Close()

    It doesn't give any errors but at the same time, it doesn't seem to do the work.

    I have looked at the link you provided, but I don't know what it's going to do (if I follow all those instructions). What kind of application settings would it save, etc.

    Thanks!
    What happens here that is the problem. Does it write a blank file ? Does it not load back the setting ? Can you give details about the problem with this approach so we can better recommend a solution ?

  14. #14

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    Got it working now.

  15. #15

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    14

    Re: Saving textbox1.text to .txt file

    Quote Originally Posted by ident View Post
    Why are you using a textfile when you can property bind the control using my.settings.

    http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
    This works for me when I play the file (the green triangle) in VB but when I compile it and use the actual .exe file, it doesn't do the job. what am I doing wrong here?

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.