VB2005 Tips and Tricks – part 5

Use Strongly Typed Configuration Settings

Double Click the My Project node in the Solution Explorer and select the Settings tab. Add the Name, Type, Scope and Value of your setting.

From your code, type:

dim aSetting as string
aSetting=My.Settings.YourSettingName

Updating User Settings

If you select User from the Scope drop-down list, you can modify that setting in runtime. The modify your setting and save it like this:

MySettings.YourSettingName = “NewValue”
MySettings.Save()

This will create a file under Documents and Settings\[UserName]\Local Settings\Application Data\[Application Name]\[Unique Directory] for the current user only with the selected value.

Comments are closed.