<applicationSettings>
<WindowsApplication1.My.MySettings>
<setting name="Astrology" serializeAs="String">
<value>6</value>
</setting>
<setting name="Cricket" serializeAs="String">
<value>7</value>
</setting>
<setting name="Foreigncurrency" serializeAs="String">
<value>8</value>
</setting>
<setting name="Jobs" serializeAs="String">
<value>9</value>
</setting>
</WindowsApplication1.My.MySettings>
</applicationSettings>

I want to display 6, 7, 8, 9 in different textboxes.
How can I do that in VB.NET2005
Please help

Dani AI

Generated

A quick sanity check: 's answer is the simplest — assign each setting to the TextBox.Text in your form (that is the usual quick fix for a handful of controls). If you want alternatives that scale better or avoid putting assignments in Form_Load, these options work well.

You can bind settings at design time so Visual Studio keeps the wiring for you: open the form in the Designer, select a TextBox, open the Properties window, expand (ApplicationSettings) or DataBindings and bind the Text property to the appropriate My.Settings entry. This creates a live binding that reads the setting at runtime (and, for user-scoped settings, can push changes back).

Programmatic data binding (one line per control) keeps code minimal and supports two-way updates:

TextBox1.DataBindings.Add("Text", My.Settings, "Astrology", True, DataSourceUpdateMode.OnPropertyChanged)

For many controls, use a name-to-control map and reflection to populate them in a loop so you do not repeat code. Example pattern:

Dim map As New Dictionary(Of String, TextBox)
map.Add("Astrology", txtAstrology)
map.Add("Cricket", txtCricket)
' ...
For Each kvp As KeyValuePair(Of String, TextBox) In map
    Dim prop = My.Settings.GetType().GetProperty(kvp.Key)
    If prop IsNot Nothing Then
        kvp.Value.Text = Convert.ToString(prop.GetValue(My.Settings, Nothing))
    End If
Next

Cautions: check each setting's Scope in the Settings designer — application-scoped settings are read-only at runtime, user-scoped settings can be changed and persisted with My.Settings.Save(). The MS docs cover binding and scopes in detail: and Application settings overview.

Recommended Answers

All 3 Replies

Have you tried

txtbox1.text = My.Settings.Astrology
txtbox2.text = My.Settings.Cricket
txtbox3.text = My.Settings.Foreigncurrency
txtbox4.text = My.Settings.Jobs

Thanks for your reply ptaylor965 it helped me.
THANKS ALOT.

Is there any other method??????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.