-
Feb 19th, 2012, 04:00 PM
#1
Thread Starter
New Member
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
-
Feb 19th, 2012, 04:25 PM
#2
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
-
Feb 19th, 2012, 04:42 PM
#3
Thread Starter
New Member
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?
-
Feb 19th, 2012, 04:45 PM
#4
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.
-
Feb 19th, 2012, 05:00 PM
#5
Thread Starter
New Member
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!
-
Feb 19th, 2012, 05:05 PM
#6
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.
-
Feb 19th, 2012, 05:32 PM
#7
Thread Starter
New Member
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
-
Feb 19th, 2012, 05:38 PM
#8
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"
-
Feb 19th, 2012, 05:56 PM
#9
Thread Starter
New Member
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
-
Feb 19th, 2012, 06:08 PM
#10
Thread Starter
New Member
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?
-
Feb 19th, 2012, 06:50 PM
#11
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.
-
Feb 19th, 2012, 07:10 PM
#12
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.
-
Feb 19th, 2012, 07:22 PM
#13
Re: Saving textbox1.text to .txt file
Originally Posted by Y0MANNN
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 ?
-
Feb 19th, 2012, 08:31 PM
#14
Thread Starter
New Member
Re: Saving textbox1.text to .txt file
-
Feb 19th, 2012, 08:53 PM
#15
Thread Starter
New Member
Re: Saving textbox1.text to .txt file
Originally Posted by ident
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|