Hello,
There's probably an overly simple answer to this, but I would like to be able to type in a value for a textbox during runtime, and then when the program is restarted, it retains the changes. I know I can create a text file, and then read from the textfile to keep up with changes, but is there a quick and dirty way to save the value for the control directly?
I'm using VB.NET 2005.
Thanks,
Sam
Scott LyslePosted Jan 20, 2009, 4:03 AM
Create and use settings for that. If you open the project settings you can name a setting, set it to be a user setting (something the user can edit) and set an initial value for it.
On form load, you can populate the text box with the setting content (e.g., here is one called 'KeptText'):
TextBox1.Text =
My.Settings.KeptTextYou can then write an event handler to update the KeptText value if the user keys in a new value:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged My.Settings.KeptText = TextBox1.Text My.Settings.Save() End Sub