Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Application Settings in VB 2005
 »  Home  »  Windows Development  »  Visual Basic 2005  »  Application Settings in VB 2005
 »  Home  »  Windows Development  »  Win Forms  »  Application Settings in VB 2005
Application Settings in VB 2005
by Ged Mead | Published  11/09/2006 | .NET Newbie Visual Basic 2005 Win Forms | Rating:
Ged Mead

Ged Mead (XTab) is a Microsoft Visual Basic MVP who has been working on computer software and design for more than 25 years. His journey has taken him through many different facets of IT. These include training as a Systems Analyst, working in a mainframe software development environment, creating financial management systems and a short time spent on military laptop systems in the days when it took two strong men to carry a 'mobile' system.

Based in an idyllic lochside location in the West of Scotland, he is currently involved in an ever-widening range of VB.NET, WPF and Silverlight development projects. Now working in a consultancy environment, his passion however still remains helping students and professional developers to take advantage of the ever increasing range of sophisticated tools available to them.

Ged is a regular contributor to forums on vbCity and authors articles for DevCity. He is a moderator on VBCity and the MSDN Tech Forums and spends a lot of time answering technical questions there and in several other VB forum sites. Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, and DevCity.NET Newsletter Editor. He has written and continues to tutor a number of free online courses for VB.NET developers.

 

View all articles by Ged Mead...
Introduction

Introduction

   Application and User Settings have been given a facelift in VB2005.   One of the questions that has appeared in VBCity Forums many times over the past few years is the one where someone wants to know how to save user choices, UI settings or other small items of data that have been input by users.  Traditionally, going back to Classic VB days this has been done by using the SaveSettings and GetSettings functions which access the Registry to write and read back the data.

   This approach still works and can be used in all versions of VB.NET, including 2005.     While it's not difficult to use, I've never thought of it as particularly intuitive either. So it's good to see that in Visual Studio 2005 there is a very easy to use visual feature available from the Project Properties tab.  You are then able to navigate through the available settings in code with ease, thanks to the My.Settings feature.  

   The examples shown in this article are designed for Beginner Level developers as an introduction to the topic.    Fire up a new VB 2005 Windows Forms Project and we'll put My.Settings through its paces.

Accessing the Settings Editor at Design Time

    You can use the Settings Editor at design time to set up the names and Types of data for which  you want to be able to store settings.  To access this editor, use your favourite technique to get to the project's Properties window, e.g. by right clicking the project name and selecting "Properties":

or from the main menu:

  The initial view of the Settings Tab in the Project's property Pages will look like this:

     Creating new Settings is a very easy process as we will see.

 

 

 

Comments    Submit Comment

Comment #1  (Posted by TobyT on 11/09/2006)
Rating
Good for beginners.
 
Comment #2  (Posted by an unknown user on 12/05/2006)
Rating
Usefull feature i've never heard about before, nice article.
 
Comment #3  (Posted by an unknown user on 12/16/2006)
Rating
It is good for beginners & and to those that are not familiar with VB 2005.
 
Comment #4  (Posted by Michael Ifland on 02/11/2007)
Rating
Thank You.
 
Comment #5  (Posted by Majed on 02/21/2007)
Rating
Still too many details are missing.
 
Comment #6  (Posted by an unknown user on 08/18/2007)
Rating
Ged's articles just keep getting better and better. Being a complete newbie I really appreciate the in depth explanation of details that I am sure are common knowledge to others.
 
Comment #7  (Posted by an unknown user on 10/19/2007)
Rating
Good beginner article
 
Comment #8  (Posted by Noname on 01/04/2008)
Rating
One big mistake:

In page 2, the formsize is set without ";" (semicolon) between size values which gives error. Developers must add ; to overcome error.
 
Comment #9  (Posted by Ged Mead on 01/05/2008)
Rating
Hi "NoName". Thanks for pointing out this problem. I suspect that in truth, this may not be so much a big mistake as a fairly common locaization/internationalisation issue which occurs in many prjects where dates, times and numbers etc are used. This is because in many Western cultures, such as here in UK, we use commas, whereas elsewhere semicolons are used as delimiters.
All I can say for sure is that the sample works perfectly on my English UK system. I'm sorry if it has caused you problems.
 
Comment #10  (Posted by i.write.code on 01/22/2008)
Rating
Perfect! Thanks for pointing out the Save and Reset methods. I was pulling out my hair over settings that always seemed to reset on their own when my application was restarted.
 
Comment #11  (Posted by Rob 73 on 05/02/2008)
Rating
Just want to say thank your for a very clear, easy to follow and extremely useful article. I was initially reluctant to try using the 'my.settings' as i 'thought' it was difficult and complex when saving user preferences, and as a result nearly tore all my hair out trying to read and write from/to text files.
Thanks from me and my 'Not so bald head'
Keep up the good work!


 
Comment #12  (Posted by Hun Makinski on 10/12/2008)
Rating
standards an easy to use enviroment. ,
 
Comment #13  (Posted by Paul Qerch on 10/12/2008)
Rating
interact with all the junk coming from social blogs, ,
 
Sponsored Links