How would I save the contents in the textbox so that next time the form containing the textbox is opened, it will still have the same text?
Printable View
How would I save the contents in the textbox so that next time the form containing the textbox is opened, it will still have the same text?
Just add a settings file to your project and save it there
Project > add new item > general > settings file
Take a look at this thread on how to use the file: http://www.vbforums.com/showthread.php?t=579165
How would I use it to save text
Im using something like this and it doesnt work Nothing shows up in the textbox
Code:Public Class Dialog1
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
TextBox1.Text = My.Settings.TextBoxUser
My.Settings.Save()
Me.Close()
End Sub
Code:Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox2.Text = My.Settings.TextBoxUser
End Sub
End Class
try Application Settings.
in your design time view, select the textbox.
expand [ApplicationSettings] in the properties window.
select 'text' + click the dropdown arrow to the right.
click 'New', type in a name for the property + click OK.
thats all you need to do + your text will be saved when you close your application + reloaded when you run it next time.