Question [Help]Save value in textbox?

neraniggy

New member
Joined
Aug 30, 2010
Messages
2
Programming Experience
Beginner
Hello Everyone!

I have a textbox, and a checkbox next too it.
If i type "VB.net Forums" in the textbox and then i click on checkbox
I want it too save the value in textbox so next time i open the
application it is there.. Do anyone know how too do this?
I bet it is pretty simple but Im new too programming, and I looked everywhere for answers too my question.
I hope someone could help me or someone has a link that helps me.
[VB.net]

hope I didnt post in the wrong forum, were so many ;)


Thanks everyone.
 
on the Application tab, check "Save My.Settings on shutdown". then create the variable on the "Settings" tab.

to access the variable, simply type "My.Settings.'your variable name here'.
 
on the Application tab, check "Save My.Settings on shutdown". then create the variable on the "Settings" tab.

to access the variable, simply type "My.Settings.'your variable name here'.
Thanks for you reply, i tried that earlier then "My" comes as error(warning?) - it has a blue line under it..

I want it too store the value in textbox when I the checkbox is checked... until i remove it myself, I basicly tried everything with my LITTLE knowledge. Would really need help so i can move on with my program
 
Last edited:
In order to do this, go to application properties, then the settings tab. Create a new setting with the name "TextToSave" and make sure it's set to string.

Now, this is how you do it:
VB.NET:
Public Class Form1

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        My.Settings.Save()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtInput.Text = My.Settings.TextToSave
    End Sub

    Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
        If chkSave.Checked = True Then
            My.Settings.TextToSave = txtInput.Text
        End If
    End Sub

End Class
 
Last edited:
Back
Top