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) has been around computers since the 1980's when the first affordable home computers came on the market. His journey from that very first Dragon 32 to the present has taken him through many different facets of the IT Industry. These include formal training as a Systems Analyst, employment in a mainframe software development environment, and a short time spent demonstrating rugged military IT systems in the days when it took two strong men to carry a 'mobile' system.

His most rewarding challenge was the creation of a financial management system for a large organisation.

Now based in an idyllic lochside location in the West of Scotland, he is currently involved in a range of development projects, whenever he can drag his gaze away from the stunning surrounding views, that is!

Ged is a Microsoft MVP, Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, Helper of the Month competition winner and DevCity.NET newsletter Editor.

 

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!


 
Sponsored Links