Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Creating, Using and Saving My.Settings Default Values in Visual Basic 2005  »  Saving Setting value changes at runtime
 »  Home  »  Visual Studio 2005  »  Creating, Using and Saving My.Settings Default Values in Visual Basic 2005  »  Saving Setting value changes at runtime
Creating, Using and Saving My.Settings Default Values in Visual Basic 2005
by Dave Barr | Published  05/29/2006 | .NET Newbie Visual Studio 2005 | Rating:
Dave Barr
Not much to tell, so for now view some of my custom logo designs, and a photograph of mine that made it to the local newspaper. 

View all articles by Dave Barr...
Saving Setting value changes at runtime

Add a Form1_FormClosing event. Type this code:

My.Settings.DefaultName = Me.TextBox1.Text

Now press F5 to run. This time, change the text in the textbox from 3-bSoftware.com to your name. Close the form. Close the project. Close Visual Studio. If you like, you can restart your computer too.

Next time you run the "VbCity Sample Project" you will see the name you just typed in the TextBox.

You can use this same process to save any of the 'User Scope' variable changes. Try practising by saving different values for the DefaultColors, or DefaultFont. Good luck!

Thank you for reading my article, Dave.

 

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:4.65 out of 5
 20 people have rated this page
Article Score12453
Comments    Submit Comment

Comment #1  (Posted by an unknown user on 06/01/2006)
Rating
Very clear to follow. All actions mentioned.
 
Comment #2  (Posted by an unknown user on 06/13/2006)
Rating
Thanksssssssssssssssssssssssss so much

vbapr@yahoo.com
 
Comment #3  (Posted by Mark on 06/23/2006)
Rating
What about writing an reading the settings programmatically?Can we do that?any examples would be fantastic
 
Comment #4  (Posted by an unknown user on 06/23/2006)
Rating
What about reading pages 3 and 4 where it's explained?

Page 3:
Me.BackColor = My.Settings.DefaultFormColor
Me.TextBox1.Font = My.Settings.DefaultFont
Me.TextBox1.ForeColor = My.Settings.DefaultFontColor
Me.TextBox1.Text = My.Settings.DefaultName

Page 4:
My.Settings.DefaultName = Me.TextBox1.Text
 
Comment #5  (Posted by an unknown user on 07/01/2006)
Rating
Thank You! Great and Simple.
 
Comment #6  (Posted by an unknown user on 07/02/2006)
Rating
Great!
 
Comment #7  (Posted by an unknown user on 07/03/2006)
Rating
Easy to follow, thank you.
 
Comment #8  (Posted by an unknown user on 09/01/2006)
Rating
Thanks Alot;;There is no way to change app level settings during setup/runtime ?
 
Comment #9  (Posted by an unknown user on 09/01/2006)
Rating
DAVE PASSED AWAY ON JULY 31, 2006.
 
Comment #10  (Posted by an unknown user on 10/05/2006)
Rating
My condolences, looks like a great guy. Great tutorial as well.
 
Comment #11  (Posted by an unknown user on 10/21/2006)
Rating
Thank you very much!

Johannes
 
Comment #12  (Posted by an unknown user on 11/07/2006)
Rating
The best and easiest way to save app settings! Thanks!!:D

//Fredrik Ragnarsson
SWEDEN
frrag001@hotmail.com
 
Comment #13  (Posted by an unknown user on 12/06/2006)
Rating
just a perfect example...
 
Comment #14  (Posted by an unknown user on 04/18/2007)
Rating
It really solve my problems with new Settings of VS2005!!!
 
Comment #15  (Posted by an unknown user on 05/09/2007)
Rating
Short and Clear. ThanX
Ralph
 
Comment #16  (Posted by Chris Walker on 07/12/2007)
Rating
The new way to do this in VS 2005 is to use PropertyBinding. It does the same thing, but without any code.

Add a control to a form, view the properties of that control, go to ApplicationSettings, there you will see PropertyBinding. Opent that up, pick a property, give it a new name to save the settings to, and viola, you are done.
 
Sponsored Links