Hi all. I am coding a program and I want it to save what the user types in for next load up.

So for example...

User types 'hello' in texbox1
User closes program.
User opens program few days later.
User sees in textbox1 it says 'hello'

Any ideas how to do this?:)
(I done a quick search on daniweb and internet and found noting that worked)
(Sorry if i make no sense to, I don't know a good way to explain it:( )

Member Avatar for P0lT10n

Hello, i dont know how to use .INI for save something... but you can go to, my project, Resources, and complete in Name the Variable name, and in value the value to save. If you want to modify use My.Resources.YOURSTRINGNAME, but only you can read it.

Using .txt File.

Public Class Form1

    Private myCoolFile As String = "C:\test.txt" '// your file.

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        IO.File.WriteAllText(myCoolFile, TextBox1.Text) '// overwrite/create file.
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myCoolFile) Then '// check if file exists.
            TextBox1.Text = IO.File.ReadAllText(myCoolFile) '// load file content.
        End If
    End Sub
End Class

Using My.Settings.

From the vb.net top Menu, click Project and select yourApplication Properties...
Locate the Settings Tab and add
"valid" as your setting Name.

Serial number thread.

I created a String setting named "myCoolText".
Just make sure your Application has been previously saved.

Public Class Form1

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        My.Settings.myCoolText = TextBox1.Text
        My.Settings.Save()
    End Sub

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

Or ApplicationSettings.
http://www.daniweb.com/forums/post1330523.html#post1330523

Thank you all so much!:D

I used the string method to save all the information using a checkbox. (if the checkbox is ticked then save info, if not then don't)

You both helped me and I thank you alot:D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.