How do you make a program remember settings. For example, first it prompts you for your name, then when you close out of it and start it again, it will display your name?
Printable View
How do you make a program remember settings. For example, first it prompts you for your name, then when you close out of it and start it again, it will display your name?
Open the Settings page of the project properties and add a setting of the appropriate type with the appropriate name. You can then access that setting in code via the so-named property of My.Settings. Settings are automatically saved to the user config file at shutdown and loaded at startup. These settings are user-specific, so if you log into Windows as a different user then your app will have a different set of settings.
Use the Settings tab of project properties to create a setting and you can access it from code like:-
The above is how you would access a setting named UserName created in the Settings tab.vbnet Code:
Dim uname As String = My.Settings.UserName
I see, but to start it up, should it be like this?
Name= My.Settings.Username
Label1.Text = Name
Sorry I am pretty much a complete beginner at programmer so Im probably way off.
Sorry I don't have my computer with me so I can't check right now.
I see thanks for all your help guys