Share via


How to: Read Application Settings in Visual Basic

You can read a user setting by accessing the setting's property on the My.Settings object.

The My.Settings object exposes each setting as a property. The property name is the same as the setting name, and the property type is the same as the setting type. The setting's Scope indicates if the property is read-only; the property for an Application scope setting is read-only, while the property for a User scope setting is read-write. For more information, see My.Settings Object.

Example

This example displays the value of the Nickname setting.

Sub ShowNickname()
    MsgBox("Nickname is " & My.Settings.Nickname)
End Sub

For this example to work, your application must have a Nickname setting, of type String. For more information, see How to: Add or Remove Application Settings.

See Also

Tasks

How to: Change User Settings in Visual Basic

How to: Persist User Settings in Visual Basic

How to: Create Property Grids for User Settings in Visual Basic

How to: Add or Remove Application Settings

Reference

My.Settings Object

Other Resources

Managing Application Settings