|
-
Mar 26th, 2012, 07:50 PM
#1
Thread Starter
Lively Member
[RESOLVED] Remembering Settings
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?
"When ideas and actions fuse, they form creations"
-
Mar 26th, 2012, 07:54 PM
#2
Re: Remembering Settings
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.
-
Mar 26th, 2012, 07:55 PM
#3
Re: Remembering Settings
Use the Settings tab of project properties to create a setting and you can access it from code like:-
vbnet Code:
Dim uname As String = My.Settings.UserName
The above is how you would access a setting named UserName created in the Settings tab.
-
Mar 26th, 2012, 08:11 PM
#4
Thread Starter
Lively Member
Re: Remembering Settings
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.
"When ideas and actions fuse, they form creations"
-
Mar 26th, 2012, 08:24 PM
#5
Re: Remembering Settings
 Originally Posted by Brinith
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.
When you tried that, did it work?
-
Mar 26th, 2012, 09:32 PM
#6
Thread Starter
Lively Member
Re: Remembering Settings
Sorry I don't have my computer with me so I can't check right now.
"When ideas and actions fuse, they form creations"
-
Mar 26th, 2012, 09:38 PM
#7
Re: Remembering Settings
 Originally Posted by Brinith
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.
Yep.....or make it simpler:-
vbnet Code:
Label1.Text = My.Settings.Username
-
Mar 26th, 2012, 09:41 PM
#8
Thread Starter
Lively Member
Re: Remembering Settings
I see thanks for all your help guys
"When ideas and actions fuse, they form creations"
-
Mar 26th, 2012, 09:43 PM
#9
Thread Starter
Lively Member
Re: Remembering Settings
 Originally Posted by jmcilhinney
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.
Well it's for a school project so I don't think that should be a problem.
"When ideas and actions fuse, they form creations"
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|