Articles → .NET → My.Settings in vb.net

My.Settings in vb.net






Software





Technical knowledge











My.Settings















How we can access it






Picture showing the project structure of the sample application

Click to Enlarge





Picture showing the settings tab in the project properties

Click to Enlarge


Scope of settings









How settings are stored




Picture showing how the settings are stored

Click to Enlarge



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
			<section name="MySettingsDemo.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
		</sectionGroup>
		<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
			<section name="MySettingsDemo.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
		</sectionGroup>
	</configSections>
	<userSettings>
		<MySettingsDemo.My.MySettings>
			<setting name="User_Preference" serializeAs="String">
				<value>P1</value>
			</setting>
		</MySettingsDemo.My.MySettings>
	</userSettings>
	<applicationSettings>
		<MySettingsDemo.My.MySettings>
			<setting name="Server_Name" serializeAs="String">
				<value>ABCD</value>
			</setting>
		</MySettingsDemo.My.MySettings>
	</applicationSettings>
</configuration>






<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<userSettings>
		<MySettingsDemo.My.MySettings>
			<setting name="User_Preference" serializeAs="String">
				<value>HH:MM</value>
			</setting>
		</MySettingsDemo.My.MySettings>
	</userSettings>
</configuration>



How to get and set the value of settings




My.Settings.<setting_name> = value;  like 'My.Settings.User_Preference = "HH:MM"


Variable_name = My.Settings.<setting_name>;



Posted By  -  Karan Gupta
 
Posted On  -  Sunday, July 6, 2014

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250